Reputation: 2983
Why does this code return a cell?
static NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
But when I am trying to get cell with
[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]
it does not return anything. Does anybody know how it is possible?
Upvotes: 1
Views: 4552
Reputation: 34912
According to Apple's documentation:
Return Value
An object representing a cell of the table or nil if the cell is not visible or indexPath is out of range.
So if that cell is not currently visible then it will return nil
. So, is it visible?
Other than that - check that you are actually creating cells in cellForRowAtIndexPath:
as you haven't specifically shown that you are.
Upvotes: 1