IPhone: output result controller, do not use sections in a UITableView

I am using the selected result controller, which seems to want to customize using sections in my UITableView. Well, in this case, I do not want to use partitions. Which is easy enough to set the value for numberOfSectionsInTableView: to 1. But now I'm not sure how to get numberOfRowsInSection: to return all cells in one section.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section];
    return [sectionInfo numberOfObjects];
}

How can I get this method to return all cells since I want to use only 1 section?

+3
source share
2 answers

, :

NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];

, nil sectionNameKeyPath. tableView:numberOfRowsInSection .

+3

, fetchedResultsController sectionNameKeyPath = nil, fetchedResultsController - ONE . Apple fetchedResultsController.

, 1 0, , 0 OfRowsInSection-1.

, .

+1

Source: https://habr.com/ru/post/1748704/


All Articles