samvermette/SVPullToRefresh — pull request #2 by twobitlabs (2012-04-25 18:26:31+00:00)
Title: Fix retain cycle

Sam, nice work on this. One problem, which I've found in nearly all PTR implementations, is that you have a retain cycle. I updated the demo code to reference the SVPullToRefresh in a __block variable. Otherwise the controller gets retained when the block is copied, and it will never be released.

I also made the scrollView property weak instead of strong. The scroll view retains SVPullToRefresh in its subviews array. If SVPullToRefresh also retains the scrollView, neither will ever be released.

The problem is easy to reproduce in the Allocations instrument. Just tap the launch button, navigate back up, rinse, repeat. You'll see new instances SVController, SVPullToRefresh, and UITableView every time you launch the controller, which are never deallocated.