Trying to understand UITableView's dequeueReusableCellWithIdentifier
Hi everyone:
Say, I have the following code in tableView:cellForRowAtIndexPath:
I have "number of rows" set to 4.
So, my understanding was that if I init a table view cell with one identifier, the next time it will be reused in a call to dequeueReusableCellWithIdentifier: if the same identifier is used. Then why do I get initWithStyle:reuseIdentifier: called 4 times in the example above?
Say, I have the following code in tableView:cellForRowAtIndexPath:
static NSString* strCellID = @"mycell";
UITableViewCell* pCell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:strCellID];
if(pCell == nil)
{
pCell = [[[UITableViewCell alloc] initWithStyle:UITableViewStylePlain reuseIdentifier:strCellID] autorelease];
}
I have "number of rows" set to 4.
So, my understanding was that if I init a table view cell with one identifier, the next time it will be reused in a call to dequeueReusableCellWithIdentifier: if the same identifier is used. Then why do I get initWithStyle:reuseIdentifier: called 4 times in the example above?
MacBook Pro 17", 2.66 GHz i7, 4GB 1067 DDR3 RAM, OS X 10.6.4 /// iPhone 4, 32GB, iOS 4