Graphics Programs Reference
In-Depth Information
Build and run the application now, and you'll see a UITableView populated with a list
of random BNRItem s. Yep, it was that easy. You didn't have to change anything about
BNRItem - you simply changed the controller object and let the controller interface with
a different view. This is why Model-View-Controller is such a powerful concept. With a
minimal amount of code, you were able to show the same data in an entirely different
way.
Reusing UITableViewCells
iOS devices have a limited amount of memory. If we were displaying a list with thousands
of entries in a UITableView , we would have thousands of instances of UIT-
ableViewCell . And your long-suffering iPhone would sputter and die. In its dying
breath, it would say “You only needed enough cells to fill the screen... arrrghhh!” It would
be right.
To preserve the lives of iOS devices everywhere, you can reuse table view cells. When the
user scrolls the table, some cells move offscreen. Offscreen cells are put into a pool of
cells available for reuse. Then, instead of creating a brand new cell for every request, the
data source first checks the pool. If there is an unused cell, the data source configures it
with new data and returns it to the table view.
Figure 9.16 Reusable UITableViewCells
Search WWH ::




Custom Search