简体   繁体   中英

Using NSFetchedResultsController and UISearchDisplayController crashes app

I have successfully implemented NSFetchedResultsController and UISearchDisplayController together on my app, the app will crash ONLY after using the UISearchDisplayController (after pressing on its Cancel button), the crash happens exactly while scrolling down the table view, the console shows this message:

Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'no object at index 5 in section at index 0'

giving that scrolling down the table view before using the UISearchDisplayController will not crash the app.

what is the problem reason in this case ?

I had a similar problem with one of my apps, when the Apple released the new iOS 4.0. Search:

fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:[self managedObjectContext] sectionNameKeyPath:nil cacheName:nil];

And set the value of the parameter cacheName to nil. It worked for me, hope it will for you. It is not necessary to create new fetch result controller each time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM