I have an application that has a UITableView with various custom UITableViewCells (and cell identifiers).
In my implemented tableView:cellForRowAtIndexPath:
method I use the UITableView's dequeueReusableCellWithIdentifier:
method and it gives me a UITableViewCell of the expected type when called during a user scrolling the table, but, if I try to retrieve a reusable cell in other parts of the code I'm getting nil as result, thus having to instantiate a new cell.
For example, the code I have that inserts new objects to be displayed looks like the following:
...
[myDataSource addObject:newObject];
...
[self.tv beginUpdates];
[self.tv insertRowsAtIndexPaths:paths withRowAnimation:rowAnimation];
[self.tv endUpdates];
...
That triggers an tableView:cellForRowAtIndexPath:
and on that call the dequeueReusableCellWithIdentifier:
returns nil although the cell that just left the screen was of the same type (same cell identifier) I'm inserting.
Shouldn't it be giving a reusable cell? In my case this may become problematic since my cells have a somewhat "heavy" init method due to their complexity.
Thanks in advance
Edit1: Just to clarify, I want to know why are no unused cell instances in the table cache to return since some cells (of the same type I'm inserting) just quit being visible?