Click here to support Nimbus development and make a donation at www.pledgie.com !
An iOS framework whose growth is bounded by O(documentation).
View Recyling

Overview

For recycling views in scroll views.

View recycling is an important aspect of iOS memory management and performance when building scroll view. When you use UITableView you use view recycling via the table cell dequeue mechanism. NIViewRecycler implements this recycling functionality, allowing you to implement recycling mechanisms in your own views and controllers.

Example Use

Imagine building a UITableView. We'll assume that a viewRecycler object exists in the view.

Views are usually recycled once they are no longer on screen, so within a did scroll event we might have code like the following:

for (UIView<NIRecyclableView>* view in visibleViews) {
  if (![self isVisible:view]) {
    [viewRecycler recycleView:view];
    [view removeFromSuperview];
  }
}

This will take the views that are no longer visible and add them to the recycler. At a later point in that same did scroll code we will check if there are any new views that are visible. This is when we try to dequeue a recycled view from the recycler.

UIView<NIRecyclableView>* view = [viewRecycler dequeueReusableViewWithIdentifier:reuseIdentifier];
if (nil == view) {
  // Allocate a new view that conforms to the NIRecyclableView protocol.
  view = [[[...]] autorelease];
}
[self addSubview:view];

Classes

class  NIViewRecycler
 An object for efficiently reusing views by recycling and dequeuing them from a pool of views. More...
protocol  <NIRecyclableView>
 The protocol for a recyclable view. More...
Generated for Nimbus by doxygen 1.7.4-20110629