Re: Reusable Cells
Re: Reusable Cells
- Subject: Re: Reusable Cells
- From: JD Guzman <email@hidden>
- Date: Thu, 03 Feb 2011 16:13:24 +0000 (GMT)
Thanks for your reply Luke, and that was a great explanation. In the end it was me misunderstanding how the mechanism works. Your succeeded in making something that seemed like voodoo to me, become much clearer and less voodoo and more clever engineering.
Regards,
JD
On Feb 02, 2011, at 08:26 PM, Luke Hiesterman <email@hidden> wrote:
Welcome to the list and the platform, JD. The purpose of the cell reuse queue is so that we don't have to keep creating new cell objects as we scroll a table. We take advantage of the fact that as new cells are appearing, old cells are disappearing. Rather than throw the old cells away and create new ones, we reuse them. We can take advantage of this same principle in other situations besides scrolling, such as reloading.
So, to answer your question of why you enter the if statement more than once, it's because each cell on screen is still a unique cell object. Therefore we have to create at least as many cells as are on the screen. A cell does not enter the reuse queue until it goes off screen, and as long as there is nothing in the queue, attempts to dequeue a cell will return nil. If you were to scroll your table or reloadData, you would find instances where you did get a valid cell out of the queue.
Luke
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden