I have a NSFetchResultsController that loads up my tableview.
When the app is first downloaded, there will be no data to show in the tableview so I want to have a static image with instructions on it. I have the following code and I call this method in viewWillAppear but it doesn’t function right. Any ideas?
- (void)checkIfEmpty
{
if ([self.fetchedResultsController fetchedObjects] > 0)
{
self.defaultImage.hidden = NO;
self.logTableView.hidden = YES;
}
else
{
self.defaultImage.hidden = YES;
self.logTableView.hidden = NO;
}
}
[self.fetchedResultsController fetchedObjects] > 0will always be true because even an empty array is an object (and notnil).You need to use
self.fetchedResultsController.fetchedObjects.count > 0instead.