I have a table view with sections.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return numberHigherThen0;
}
in cellForRowAtIndexPath method I setup my rows according to section
- (UITableViewCell *)tableView:(UITableView *)aTableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (0 == indexPath.section) {
//setup rows
} esle {
//setup rows
}
}
numbers of sections and rows in sections changes dynamically. But numbers of sections always > 0. So in cellForRowAtIndexPath indexPath.section == 0 there will be always this case, right ? But some times cellForRowAtIndexPath didn’t pass case indexPath.section == 0 !!! Why ? When it can be true ? When cellForRowAtIndexPath can start count sections from 1 ?
Update:
section 2 has no rows
In numberOfSectionsInTableView: you specify the number of sections – however, the sections are numbered from 0.
So if you return 3 in your numberOfSectionsInTableView you will have three sections – section 0, section 1, and section 2.