Skip to content

Instantly share code, notes, and snippets.

@kreeger
Created October 11, 2012 16:00
Show Gist options
  • Save kreeger/3873395 to your computer and use it in GitHub Desktop.
Save kreeger/3873395 to your computer and use it in GitHub Desktop.
Removing "empty" cells from a section.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSInteger count = [[[self.tableSettings objectAtIndex:section] objectForKey:@"rows"] count];
NSInteger emptyCount = 0;
for (int i = 0; i < count; i++) {
NSIndexPath *iPath = [NSIndexPath indexPathForRow:i inSection:section];
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:iPath];
if (cell.textLabel.text == nil || [cell.textLabel.text isEqualToString:@""]) emptyCount++;
}
return (count - emptyCount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment