Restore from backup causes app crash - ios

I've been struggling with Core Data for 3 days now and I'm only going backwards. I had to restore my entire project from a backup and now I get this:
2014-01-06 14:47:45.911 MyClub[1980:5003] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't merge models with two different entities named 'SuperGroups''
*** First throw call stack:
(
0 CoreFoundation 0x0000000101e70795 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000101bd3991 objc_exception_throw + 43
2 CoreData 0x00000001000fba1d +[NSManagedObjectModel modelByMergingModels:] + 3357
3 CoreData 0x00000001000b8e49 +[NSManagedObjectModel mergedModelFromBundles:] + 521
4 MyClub 0x0000000100008499 -[AppDelegate managedObjectModel] + 105
5 MyClub 0x00000001000085fa -[AppDelegate persistentStoreCoordinator] + 266
6 MyClub 0x000000010000836c -[AppDelegate managedObjectContext] + 92
7 MyClub 0x000000010000b112 __38-[MyDownloader populateSuperGroupList]_block_invoke + 1058
8 CFNetwork 0x000000010273240e __50-[__NSCFLocalDownloadTask _private_fileCompletion]_block_invoke227 + 83
9 Foundation 0x00000001017fc19b -[NSBlockOperation main] + 75
10 Foundation 0x000000010184a844 -[__NSOperationInternal _start:] + 623
11 Foundation 0x000000010184c71b __NSOQSchedule_f + 64
12 libdispatch.dylib 0x0000000102d4e6fd _dispatch_client_callout + 8
13 libdispatch.dylib 0x0000000102d3de37 _dispatch_queue_drain + 481
14 libdispatch.dylib 0x0000000102d3dbfc _dispatch_queue_invoke + 112
15 libdispatch.dylib 0x0000000102d3eb14 _dispatch_root_queue_drain + 257
16 libdispatch.dylib 0x0000000102d3ed65 _dispatch_worker_thread2 + 40
17 libsystem_pthread.dylib 0x00000001030f8ef8 _pthread_wqthread + 314
18 libsystem_pthread.dylib 0x00000001030fbfb9 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
What do I do (other than swear loudly and profusely at Core Data, which I've already tried multiple times)?

It appears you have two managed object models in your project (Both have an entity in them named SuperGroups). Try loading a specific one via its URL, or deleting the duplicate from your project.

Whenever you make a change to the Core Data's Object Model you have to make sure you get rid of the application on your simulator/phone. The model on the device must match the model in your code or you will get an error.
There is a process in place that will allow you to technically have two seperate models so that when you say put an update in to the app store you can do it without users having to delete all their data. If you ever need this I would look into "Core Data Versioning".

Related

Core data crash when resetting the store: 'Object's persistent store is not reachable from this NSManagedObjectContext's coordinator'

I get a crash when trying to delete the persistent store of Core data in my iOS app written in Swift. The flow is straight forward: When I log out from the app I delete the store with:
destroyPersistentStoreAtURL
I use native Core Data implementation in the application and every access to a managed object is made with performBlock/performBlockAndWait. Also, these operations are in a NSOperationQueue. The flow is the following:
Log out
cancelAllOperations & waitUntilAllOperationsAreFinished on the queue that the performBlocks are implemented
maxConcurrentOperationCount = 1 on the queue of the performBlocks
Finally, I add an operation which destroys the persistent store in the previous NSOperationQueue
Sometimes, I get a crash and I cannot understand why. From what I see, it is something related with managedObjectsIDs and retain. Take a look:
2016-11-14 15:51:58.053 ******[3912:179074] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Object's persistent store is not reachable from this NSManagedObjectContext's coordinator'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ca0f34b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010c05321e objc_exception_throw + 48
2 CoreData 0x000000010c5683b2 _PFRetainedObjectIDCore + 1074
3 CoreData 0x000000010c5507fc -[NSManagedObjectContext objectWithID:] + 668
4 CoreData 0x000000010c590264 _faultBatchAtIndex + 1524
5 CoreData 0x000000010c59217a -[_PFBatchFaultingArray retainedObjectAtIndex:] + 74
6 CoreData 0x000000010c592262 -[_PFBatchFaultingArray objectAtIndex:] + 50
7 CoreData 0x000000010c67d9de __72-[NSFetchedResultsController(PrivateMethods) _computeSectionInfo:error:]_block_invoke + 190
8 CoreData 0x000000010c55adc7 developerSubmittedBlockToNSManagedObjectContextPerform + 199
9 CoreData 0x000000010c55ac7f -[NSManagedObjectContext performBlockAndWait:] + 255
10 CoreData 0x000000010c67d3b6 -[NSFetchedResultsController(PrivateMethods) _computeSectionInfo:error:] + 694
11 CoreData 0x000000010c681d75 __82-[NSFetchedResultsController(PrivateMethods) _core_managedObjectContextDidChange:]_block_invoke + 1077
12 CoreData 0x000000010c55adc7 developerSubmittedBlockToNSManagedObjectContextPerform + 199
13 CoreData 0x000000010c55ac7f -[NSManagedObjectContext performBlockAndWait:] + 255
14 CoreData 0x000000010c681927 -[NSFetchedResultsController(PrivateMethods) _core_managedObjectContextDidChange:] + 119
15 CoreFoundation 0x000000010c9ad19c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
16 CoreFoundation 0x000000010c9ad09b _CFXRegistrationPost + 427
17 CoreFoundation 0x000000010c9ace02 ___CFXNotificationPost_block_invoke + 50
18 CoreFoundation 0x000000010c96fea2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 2018
19 CoreFoundation 0x000000010c96ef3b _CFXNotificationPost + 667
20 Foundation 0x000000010bb1b0ab -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
21 CoreData 0x000000010c5432b0 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 704
22 CoreData 0x000000010c562b50 -[NSManagedObjectContext(_NSInternalNotificationHandling) _processChangedStoreConfigurationNotification:] + 2976
23 CoreData 0x000000010c5d97ed __95-[NSManagedObjectContext(_NSInternalNotificationHandling) _sendOrEnqueueNotification:selector:]_block_invoke + 109
24 CoreData 0x000000010c55adc7 developerSubmittedBlockToNSManagedObjectContextPerform + 199
25 libdispatch.dylib 0x000000010e0250cd _dispatch_client_callout + 8
26 libdispatch.dylib 0x000000010e0058d6 _dispatch_main_queue_callback_4CF + 406
27 CoreFoundation 0x000000010c9d34f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
28 CoreFoundation 0x000000010c998f8d __CFRunLoopRun + 2205
29 CoreFoundation 0x000000010c998494 CFRunLoopRunSpecific + 420
30 GraphicsServices 0x000000010f5d0a6f GSEventRunModal + 161
31 UIKit 0x000000010a050964 UIApplicationMain + 159
32 ****** 0x000000010817e932 main + 114
33 libdyld.dylib 0x000000010e07168d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Any help is much appreciated!
You need to reset managedObjectContext which was used before this operation.
Call managedObjectContext.reset()
The error is telling you that you're still trying to use a managed object after you have destroyed the persistent store from which it was fetched. That's guaranteed to cause exactly this crash.
It's impossible to say exactly where this is happening, but if you keep any reference to a managed object after removing the store, you'll get this. Cancelling operations, using performBlock, etc, don't make any difference if at the end you're still trying to use a managed object that doesn't have a persistent store any more.
I had the same issue and Tom's hint assuming that dirty objects — that used to live in the old store — where still part of the managed object context after I removed the persistent store from the coordinator. In my case I implemented a "revert to last saved document version" which needs to make sure that these dirty objects are being discarded first.
[_managedObjectContext reset]
[_managedObjectContext.persistentStoreCoordinator removePersistentStore:_store error:outError]
If you still have references to these objects in your code, object.managedObjectContext will be nil — which is a good hint to recover.
#Tom
Yes, you are right. So I post you an example:
let queue = NSOperationQueue
queue.addOperationWithBlock{
let moc = newPrivateQueueManagedObjectContext()
moc.performBlock {
//some work to do on the context
}
and then sometime I destroy the store, but before that I cancel the operations on the above queue. Still, sometimes I see a crash...

Coredata + CollectionView

I'm trying to create an iOS app which has a collectionview that takes information from a website (with JSON) and stores the info on CoreData.
I have 2 entities on CoreData.
1 Called Regions (wich will be the collection header texts).
1 Called Distributors (which will be the collection cells).
To use CollectionView + CoreData i have seen this example: https://github.com/AshFurrow/UICollectionViewExample
I set up everthing and works but sometimes, when i rotate the devide multiple times and the collection view still scrolls i see this error:
*** Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds'
*** First throw call stack:
(
0 CoreFoundation 0x01a9f5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x015738b6 objc_exception_throw + 44
2 CoreFoundation 0x01a9f3bb +[NSException raise:format:] + 139
3 Foundation 0x011a5f62 -[NSRLEArray objectAtIndex:effectiveRange:] + 131
4 Foundation 0x011a7b86 -[NSConcreteMutableAttributedString addAttribute:value:range:] + 212
5 UIFoundation 0x034aab82 __50-[NSConcreteTextStorage addAttribute:value:range:]_block_invoke + 156
6 UIFoundation 0x034aaa65 -[NSConcreteTextStorage addAttribute:value:range:] + 127
7 DataDetectorsUI 0x0a7da85c -[DDTextKitOperation _addResultsToAttributes] + 374
8 DataDetectorsUI 0x0a7daa82 __46-[DDTextKitOperation doURLificationOnDocument]_block_invoke_2 + 39
9 UIFoundation 0x034a9190 -[NSTextStorage(ActorSupport) coordinateAccess:] + 48
10 DataDetectorsUI 0x0a7daa54 __46-[DDTextKitOperation doURLificationOnDocument]_block_invoke + 134
11 libdispatch.dylib 0x0222d440 _dispatch_barrier_sync_f_slow_invoke + 71
12 libdispatch.dylib 0x0223e4b0 _dispatch_client_callout + 14
13 libdispatch.dylib 0x0222c75e _dispatch_main_queue_callback_4CF + 340
14 CoreFoundation 0x01b04a5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
15 CoreFoundation 0x01a456bb __CFRunLoopRun + 1963
16 CoreFoundation 0x01a44ac3 CFRunLoopRunSpecific + 467
17 CoreFoundation 0x01a448db CFRunLoopRunInMode + 123
18 GraphicsServices 0x03d569e2 GSEventRunModal + 192
19 GraphicsServices 0x03d56809 GSEventRun + 104
20 UIKit 0x002e1d3b UIApplicationMain + 1225
21 CollectionTest 0x0000934d main + 141
22 libdyld.dylib 0x024ce725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I have created a demo app with everthing ready to launch it and check the error, you can download it here: https://www.dropbox.com/s/cg86896ld6240r5/CollectionTest.zip
I would appreciate any help if anyone know what could be the problem.
Thanks in advance.
I don't think this has anything to do with CoreData. I think this has to do with a bug in iOS 7 related to doURLificationOnDocument. We're running into this same problem in our app that makes no use of core data whatsoever. If you look at this stack overflow link: iOS 7 UITextView link detection crash in UITableView, you'll see that someone else is complaining about the same problem.
You are not using Core Data properly. Your entities have no relationships to each other. Instead, you are relying on some kind of foreign key. This is not appropriate for object graphs such as Core Data and can lead to all kinds of unpredictable errors, including the one you are encountering.
Read up on how Core Data models work. Pay particular attention to the chapter Relationships and Fetched Properties in the Core Data Programming Guide.

CoreData could not fulfill a fault

I have a problem with the CoreData and fulfilling managedObjects.
Stack trace:
Uncaught exception: CoreData could not fulfill a fault for '0x11cec410 <x-coredata://08BF0B39-BA5D-404E-B75E-FD4FA906DE3E/TaskDescription/p1747>'. Stack trace: (
"4 libc++abi.dylib 0x03553f60 _ZSt11__terminatePFvvE + 14",
"5 libc++abi.dylib 0x03553b97 __cxa_rethrow + 103",
"6 libobjc.A.dylib 0x02cb0a57 objc_exception_rethrow + 47",
"7 CoreFoundation 0x02f95bc5 CFRunLoopRunSpecific + 613",
"8 CoreFoundation 0x02f9594b CFRunLoopRunInMode + 123"
)
*** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0x11cec410 <x-coredata://08BF0B39-BA5D-404E-B75E-FD4FA906DE3E/TaskDescription/p1747>''
*** First throw call stack:
(
0 CoreFoundation 0x02ff05e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02cb08b6 objc_exception_throw + 44
2 CoreData 0x0298666b _PFFaultHandlerLookupRow + 2715
3 CoreData 0x02985bc7 -[NSFaultHandler fulfillFault:withContext:forIndex:] + 39
4 CoreData 0x029857a3 _PF_FulfillDeferredFault + 259
5 CoreData 0x029855f6 _sharedIMPL_pvfk_core + 70
6 CoreData 0x0298a005 -[NSManagedObject(_PFDynamicAccessorsAndPropertySupport) _genericValueForKey:withIndex:flags:] + 85
7 CoreData 0x029c3ab1 _PF_Handler_Public_GetProperty + 161
8 CoreData 0x029c39b5 -[NSManagedObject valueForKey:] + 149
9 Foundation 0x0254e065 -[NSFunctionExpression expressionValueWithObject:context:] + 1260
10 Foundation 0x025d4109 -[NSComparisonPredicate evaluateWithObject:substitutionVariables:] + 248
11 Foundation 0x025d4009 -[NSPredicate evaluateWithObject:] + 48
12 CoreData 0x02a8f991 -[NSFetchedResultsController(PrivateMethods) _objectInResults:] + 113
13 CoreData 0x02a912c2 -[NSFetchedResultsController(PrivateMethods) _preprocessUpdatedObjects:insertsInfo:deletesInfo:updatesInfo:sectionsWithDeletes:newSectionNames:treatAsRefreshes:] + 642
14 CoreData 0x02a926f4 -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 1892
15 Foundation 0x02622e39 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 40
16 CoreFoundation 0x0304c524 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
17 CoreFoundation 0x02fa407b _CFXNotificationPost + 2859
18 Foundation 0x0255cb91 -[NSNotificationCenter postNotificationName:object:userInfo:] + 98
19 CoreData 0x029974a3 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 83
20 CoreData 0x02a36abf -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] + 367
21 CoreData 0x02993168 -[NSManagedObjectContext(_NSInternalChangeProcessing) _postRefreshedObjectsNotificationAndClearList] + 136
22 CoreData 0x02992d14 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 3140
23 CoreData 0x029920c9 -[NSManagedObjectContext processPendingChanges] + 41
24 CoreData 0x02966311 _performRunLoopAction + 321
25 CoreFoundation 0x02fb853e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
26 CoreFoundation 0x02fb848f __CFRunLoopDoObservers + 399
27 CoreFoundation 0x02f963b4 __CFRunLoopRun + 1076
28 CoreFoundation 0x02f95b33 CFRunLoopRunSpecific + 467
29 CoreFoundation 0x02f9594b CFRunLoopRunInMode + 123
30 GraphicsServices 0x0488d9d7 GSEventRunModal + 192
31 GraphicsServices 0x0488d7fe GSEventRun + 104
32 UIKit 0x016c294b UIApplicationMain + 1225
33 MYAPP 0x0003bb9d main + 141
34 MYAPP 0x00003055 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type _NSCoreDataException
All I can see when app crashes is that trace with only showing some internal CoreData/Foundation instructions. Can anyone please explain me, what is going on with that
NSFetchedResultsController(PrivateMethods)
or
NSManagedObjectContext(_NSInternalChangeProcessing)
It looks very weird to me. How can I prevent from such NSObjectInaccessibleException?
I know that this error is due to previously deleted object. I have many background contexts run asynchronously, but I think that I am keeping the rules given by Apple documentation about concurrency with CoreData. It crashes only sometimes and I can't see anything from this point. Anyone had similar situation?
This has nothing to do with the methods you mentioned.
Nor can you avoid this issue in a multi-context environment where you have more then one child context with the same parent (nil parent included).
This might happen in a multi-context environment (or some unique cases) where one context hold a fault for some object (which he consider to exist) but in the mean time another context delete the object from the store and not notifying the other context of the deletion (before the context holding the fault attempt to fulfil it.
Using a FRC in a multi-context environment ,which does not use a parent child architecture where the FRC context is the parent for all child contexts will always be vulnerable to this exception.
See HERE for some more usecases.
A possible solution would be to delay your actual deletion of FRC tracked objects:
first mark them for deletion (your FRC predicate should take this new property into account)
Then use a background operation to delete objects that were marked for deletion (every given time interval)
A partial solution would be to use a parent child context architecture funnelling all events through the context the FRC is observing.
This is a partial solution due to the fact that this move the problem one level up to the child contexts that are unaware of each other deletions (if child contexts never deal with the same objects in parallel then you might avoid this issue).

Mysterious Core Data Faulting Crash

I am experiencing a mysterious Core Data crash via crash reports in my app, that I am having difficulty coming up with a theory for. No reproduction steps, no obvious causes, but it occurs many thousand times. The crash report is pretty vague but it seems to happen when an NSManagedObject is assigned via property to another? Any theories would be appreciated.
*** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0x1dc92160 <x-coredata://6903F7F9-C600-4A29-A538-B3337F1D0BED/Profile/p47854>''
Last Exception Backtrace:
1 CoreFoundation __exceptionPreprocess + 163
2 libobjc.A.dylib objc_exception_throw + 30
3 CoreData _PFFaultHandlerLookupRow + 1477
4 CoreData _PF_FulfillDeferredFault + 203
5 CoreData _PF_ManagedObject_WillChangeValueForKeywithSetMutation + 71
6 CoreData -[NSManagedObject willChangeValueForKey:withSetMutation:usingObjects:] + 84
7 CoreData -[NSManagedObject _includeObject:intoPropertyWithKey:andIndex:] + 690
8 CoreData -[NSManagedObject _maintainInverseRelationship:forProperty:oldDestination:newDestination:] + 444
9 CoreData -[NSManagedObject _didChangeValue:forRelationship:named:withInverse:] + 1290
10 CoreData -[NSManagedObjectContext observeValueForKeyPath:ofObject:change:context:] + 322
11 Foundation NSKeyValueNotifyObserver + 273
12 Foundation NSKeyValueDidChange + 335
13 Foundation -[NSObject didChangeValueForKey:] + 94
14 CoreData -[NSManagedObject didChangeValueForKey:] + 126
15 CoreData -[NSManagedObject _updateFromRefreshSnapshot:includingTransients:] + 614
16 CoreData -[NSManagedObjectContext _copyChildObject:toParentObject:fromChildContext:] + 96
17 CoreData -[NSManagedObjectContext _parentProcessSaveRequest:inContext:error:] + 554
18 CoreData __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke_0 + 565
19 libdispatch.dylib _dispatch_barrier_sync_f_slow_invoke + 81
20 libdispatch.dylib _dispatch_client_callout + 23
21 libdispatch.dylib _dispatch_main_queue_callback_4CF$VARIANT$up + 227
22 CoreFoundation __CFRunLoopRun + 1291
23 CoreFoundation CFRunLoopRunSpecific + 356
24 CoreFoundation CFRunLoopRunInMode + 104
25 GraphicsServices GSEventRunModal + 74
26 UIKit UIApplicationMain + 1120
27 My App main (main.m:18)
28 libdyld.dylib start + 0
“CoreData could not fulfill a fault” usually happens when you delete some object from the persistent store using one context, but in another context this object still exists, it is a fault, and you try to access some property of it.
Don’t forget that an object can be deleted as a result of cascade deletion rule for a relationship.
Here’s the possible timeline:
The object is fetched in context A. By default it is a fault.
The object representing the same data in the store is fetched in context B.
The object is deleted in context B.
Context B is saved resulting in data deleted from the store.
Some property of the object from context A is accessed.
The fault is being fired. Core Data tries to fulfill the fault, but there’s no data in the persistent store anymore.
If an object that was already fetched has been deleted on another thread or in a different ManagedObjectContext, it is possible that you receive an exception when you try to access a property of the deleted object.
This is due to faulting which is described here:
https://developer.apple.com/library/ios/documentation/cocoa/conceptual/CoreData/Articles/cdFaultingUniquing.html

NSFetchedResultsController issue on iOS4

I am developing an application which uses CoreData. The view contains a UITableView (containing around 50 elements) which uses a NSFetchedResultsController. There is also a "Pull to refresh" which permits to refresh the stored data after a WS call (in another thread with a new managed object context).
Everything is working fine on iOS5: the database and the tableview are refreshed when I perform a "Pull to refresh". However there is a problem with iOS4. The first "performFetch" works when the application is launched (the tableview contains all database records) but I've got the following error when I perform a "Pull to refresh":
2012-02-29 11:56:09.119 Nanopost[1996:207] *** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0x5c3c760 <x-coredata://E176B0A1-275B-4332-9231-49FD88238C2B/Ads/p231>''
*** Call stack at first throw:
(
0 CoreFoundation 0x02bfe919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02e595de objc_exception_throw + 47
2 CoreData 0x028b833f _PFFaultHandlerLookupRow + 1407
3 CoreData 0x028b5ee3 _PF_FulfillDeferredFault + 499
4 CoreData 0x028b9f3f _sharedIMPL_pvfk_core + 95
5 CoreData 0x0292a010 _PF_Handler_Public_GetProperty + 160
6 Foundation 0x02442c4f -[NSSortDescriptor compareObject:toObject:] + 128
7 CoreData 0x0297db5e +[NSFetchedResultsController(PrivateMethods) _insertIndexForObject:inArray:lowIdx:highIdx:sortDescriptors:] + 286
8 CoreData 0x0297e1b2 -[NSFetchedResultsController(PrivateMethods) _postprocessInsertedObjects:] + 402
9 CoreData 0x029841bc -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 1804
10 Foundation 0x02380c1d _nsnote_callback + 145
11 CoreFoundation 0x02bd6cf9 __CFXNotificationPost_old + 745
12 CoreFoundation 0x02b5611a _CFXNotificationPostNotification + 186
13 Foundation 0x023767c2 -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
14 CoreData 0x028c0519 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 89
15 CoreData 0x028f802b -[NSManagedObjectContext mergeChangesFromContextDidSaveNotification:] + 1579
16 Foundation 0x02395e9a __NSThreadPerformPerform + 251
17 CoreFoundation 0x02bdfd7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
18 CoreFoundation 0x02b3e2cb __CFRunLoopDoSources0 + 571
19 CoreFoundation 0x02b3d7c6 __CFRunLoopRun + 470
20 CoreFoundation 0x02b3d280 CFRunLoopRunSpecific + 208
21 CoreFoundation 0x02b3d1a1 CFRunLoopRunInMode + 97
22 GraphicsServices 0x031e62c8 GSEventRunModal + 217
23 GraphicsServices 0x031e638d GSEventRun + 115
24 UIKit 0x0063cb58 UIApplicationMain + 1160
25 Nanopost 0x0000230a main + 170
26 Nanopost 0x00002255 start + 53
)
terminate called after throwing an instance of '_NSCoreDataException'
When I initialize the "NSFetchRequest", I set the "FetchBatchSize" to 20 (randomly):
[l_FetchRequest setFetchBatchSize:20];
But if I set the "FetchBatchSize" to 25:
[l_FetchRequest setFetchBatchSize:25];
... No more crashes on iOS4 and I don't know why and I want to understand this issue :) I don't think that this line is the real problem. Maybe it indicates another problem somewhere?
Thank you very much in advance for your answers!
Thomas
Is there a reason you are using a different context? I don't switch mine, and I have a pretty similar sounding app.
One thing you might compare to is this very handy CoreDataTableViewController:
http://www.stanford.edu/class/cs193p/cgi-bin/drupal/node/289
I use it and haven't had any issues (though I am not running in iOS 4). You might compare how you hooked up the fetchedResultsController.
One other point - do you have the catch-all breakpoint to push the debugger as soon as an exception is raised? If not, add it (breakpoints, + to add, "Add Exception Breakpoint" and keep defaults). That will put you into the debugger right on the line that raises the exception, which should be useful.
Good luck,
Damien

Resources