In my viewDidLoad, I have self.todaySession = (id)[fetchedResultsController objectAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; which works fine when it finds this object. But when it doesn’t, it crashes the app. Is there a logic statemnt I can do to fix this?
In my viewDidLoad , I have self.todaySession = (id)[fetchedResultsController objectAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; which works
Share
There are a few ways of doing this depending on the context.
You can use the count of
fetchedObjectsorsectionsfrom theNSFetchedResultsController. Make sure you callperformFetch:beforehand.More Information
Read more about NSFetchedResultsController here.