Reusable Cells
Reusable Cells
- Subject: Reusable Cells
- From: JD Guzman <email@hidden>
- Date: Wed, 02 Feb 2011 10:42:24 +0000 (GMT)
Hello,
I'm new to this list and also relatively new to development on the Mac/iPhone platforms.
I was just wondering if someone could clarify how exactly dequeueReusableCellWithIdentifier: works. The reason I ask is because I have the following code:
---------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [channelList dequeueReusableCellWithIdentifier:@"channelCell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"channelCell"] autorelease];
}
[[cell textLabel] setText:[channels objectAtIndex:[indexPath row]]];
return cell;
}
---------
Now if I set a break point inside the if statement I was expecting that it would only be entered once, however it is entered every time a cell is created. Shouldn't the call to dequeueReusableCellWithIdentifier: return a cell after it has been created inside the if statement? Or am I misunderstanding how this works?
Regards,
JD_______________________________________________
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