I have an iPhone app that freezes sometimes when saving CoreData and then doesn\'t relaunch. I did have a second thread that uses the database, but I think I have followed t
So I now believe the problem was that I was sometimes writing an NSNumber with float value to an integer field. This caused the copy in memory to be different than the copy read from the database, and this caused the infinite merge loop. But if you restarted the app it worked fine because the value was simply an integer from then on.
When using Core Data from multiple threads, make sure to lock your PSC before a save operation:
[self.persistentStoreCoordinator lock];
NSManagedObjectContext *context = //your context;
[context save:&error];
if (error) {
// handle error
}
[self.persistentStoreCoordinator unlock];