[Core Data] mergeChangesFromContextDidSaveNotification: and thread safety
[Core Data] mergeChangesFromContextDidSaveNotification: and thread safety
- Subject: [Core Data] mergeChangesFromContextDidSaveNotification: and thread safety
- From: Aurélien Hugelé <email@hidden>
- Date: Fri, 29 May 2009 11:49:49 +0200
Hi !
I'm having strange crashes in my threaded core data application. Happy
WWDC is in few days!
Core Data multithreading basic rule is to avoid passing managed
objects across threads, and pass objectIDs instead.
To "synchronize" 2 mocs from 2 different threads (sharing the same
psc), I use mergeChangesFromContextDidSaveNotification:. As Apple
demonstrate in the documentation, I use performSelectorInMainThread:
since I just want to synchronize my main moc, in the main thread, with
inserted objects, created in a second moc, in a subthread. So there is
no need to lock.
But the mergeChangesFromContextDidSaveNotification: method uses the
notification as an argument, and the userInfo of this notification
contains managed objects, not objectIDs! Managed objects are then
passed from sub thread to mainthread...
Isn't it a violation of the basic rule described below?
Aurélien,
Objective Decision Team
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden