I have a problem with Core Data in iOS 9 I did not have in iOS 8.
I have an environment with multiple objects NSManagedObjectContext. The parent contexthas a concurrency type NSMainQueueConcurrencyType, and all view controllers have their own child objects context. The reason I use such a system is because I want to be more independent contextsand combine them only when I decided that this should be done. The child contextis in the private queue because he does his work in the reverse flow, and then the parent context, who is in the main thread, transfers the changes to the database and does what he needs in the main thread.
All of this worked fine until iOS 9. The behavior I get is pretty weird. For example, when I add a new object of type A, it extends to storage. If I add another object of type A to the same vc using the same contextbutton, but from a different button, performBlockAndWait:moc is not called, and my application freezes without any messages in the console. If you try to use the first button, it goes through every time.
- (BOOL)saveChildContext:(NSManagedObjectContext*)childContext
{
[childContext performBlockAndWait:^{
NSError* error;
[childContext save:&error];
[_managedObjectContext performBlock:^{
NSError* parentError;
[_managedObjectContext save:&parentError];
}];
}];
}
If I call performBlock:, it's all right. Therefore, I realized that this could be due to incorrect threading. On the other hand, using the same thread with the same type of object, but with a different button, everything is going well. This is what bothers me and raises doubts that this is due to threads.
My questions:
1) context context, , , , ?
2) iOS 8. , , performBlockAndWait:. ? , - ? , ?