childContext and parentContext are both of "NSMainQueueConcurrencyType"
[childContext performBlock:^(void) {
[childContext save:NULL];
[parentContext performBlock:^(void) {
[parentContext save:NULL];
// Why is objectID for the inserted NSManagedObject still a temporary one here?
}];
}];
Question:
I can think of a few rare occasions where you would want to have a main-queue MOC as a child of another main-queue MOC, but seeing that sure begs me to ask: What's the advantage of having both of them be NSMainQueueConcurrencyType?
Also, this is a known bug (at least it has been reported a number of times). When you insert and save from a child context, only the one directly connected to the persistent store gets its IDs mutated. So, when saving newly inserted items, you have several choices.
[moc refreshObject:object mergeChanges:NO]
and set all references to nil.I prefer #3 because it requires a dip into the database. If you do it after, it can get them from the parent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With