Closed calebd closed 10 years ago
Is there a way to do this without using the ivar?
I do something similar to this in my own table view data source. I make sure the table view is reloaded when we perform the fetch request.
I think something like the following could be cleaner (and prevents using an ivar).
- (BOOL)performFetch:(NSError **)error {
BOOL result = [[self fetchedResultsController] performFetch:error];
[[self tableView] reloadData];
return result;
}
When the fetch request is set, I would then perform the fetch.
- (void)setFetchedResultsController:(NSFetchedResultsController *)fetchedResultsController {
_fetchedResultsController = fetchedResultsController;
[self performFetch:nil];
}
I don't think there is a need to perform a reload on viewWillAppear:
. Instead just make sure the table view is updated when the fetch happens (if it happens after the table view is loaded).
What do you think @soffes @kylef?
You should probably add the same thing to the collection view variant too.
My bad on closing. Silly GitHub.
Bump.
Reload the table view the first time it is shown. This is how UITableViewController works afiak.