Categories
Computing iphone

UITableView cell recycling: knowing what’s visible

On my iOS app project, I need to know what is visible in a UITableView and what's not. Each cell displays a unique countdown timer which updates the label in the cell. UITableView recommends you let it recycle the cells used to display the table. What I could not figure out is what cell is being recycled out of the table. Still, the documentation for the recycling method dequeueReusableCellWithIdentifier is confusing (to me). 

The method's signature

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

actually returns you the cell that is being replaced.

Better yet, you can use the cell's properties to find out which cell it was. Not a major revelation but maybe it will help someone out there. You can play with my test project and see for yourself.

Share
Share