NSFetchedResultsController triggers exception
This is strange one...
When I am sorting NSFetchedResultsController by integer field (i.e. movie rating) and then changing that field in a fetched object I will get the followed exception.
Doing the above with string fields (i.e. movie name) will work perfectly.
Just note that the exception occurs only when I implement controllerDidChangeContent. Removing it will solve the issue but then I won't be able to catch content changes...
Does anyone have any idea what's going on?
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_PFCachedNumber localizedCaseInsensitiveCompare:]: unrecognized selector sent to instance 0x5ceb00c'
Call stack relevant part looks as follows:
*** Call stack at first throw:
(
0 CoreFoundation 开发者_高级运维 0x01721be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x018765c2 objc_exception_throw + 47
2 CoreFoundation 0x017236fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01693366 ___forwarding___ + 966
4 CoreFoundation 0x01692f22 _CF_forwarding_prep_0 + 50
5 Foundation 0x002ec73d _NSCompareObject + 76
6 CoreData 0x0101d68e +[NSFetchedResultsController(PrivateMethods) _insertIndexForObject:inArray:lowIdx:highIdx:sortDescriptors:] + 286
7 CoreData 0x0101dca2 -[NSFetchedResultsController(PrivateMethods) _postprocessInsertedObjects:] + 402
8 CoreData 0x0101f7d6 -[NSFetchedResultsController(PrivateMethods) _postprocessUpdatedObjects:] + 870
9 CoreData 0x01024305 -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 1765
10 Foundation 0x002ab6c1 _nsnote_callback + 145
11 CoreFoundation 0x016f9f99 __CFXNotificationPost_old + 745
12 CoreFoundation 0x0167933a _CFXNotificationPostNotification + 186
13 Foundation 0x002a1266 -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
14 CoreData 0x00f5b509 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 89
15 CoreData 0x00fcc6d3 -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] + 259
16 CoreData 0x00f3e178 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 1352
17 CoreData 0x00f77b85 -[NSManagedObjectContext save:] + 149
It would be helpful if we could see where you setup your NSFetchedResultsController. It looks like it could be a problem with the sort descriptor.
精彩评论