mdominick
mdominick

Reputation: 1319

[tableView numberOfRowsInSection:0 always returns 0

The data populates, but [tableView numberOfRowsInSection:0] always returns 0. There is only one section in my table. What types of things can cause this behavior?

Upvotes: 1

Views: 1852

Answers (2)

alloc_iNit
alloc_iNit

Reputation: 5183

If there is only one section always in your table, go with the following coed...

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return 1;
    }

Or in case your number of sections are depending on datasource, you can return the count of your datasource.

Upvotes: 4

Sanchit Paurush
Sanchit Paurush

Reputation: 6162

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];

Try this. It might help you.

Upvotes: 0

Related Questions