• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[Core Data] mergeChangesFromContextDidSaveNotification: and thread safety
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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


  • Follow-Ups:
    • Re: [Core Data] mergeChangesFromContextDidSaveNotification: and thread safety
      • From: Ben Trumbull <email@hidden>
  • Prev by Date: Re: Performance, Efficiency - Coding practice
  • Next by Date: Re: Binding to two values
  • Previous by thread: Re: Rearrange items on NSToolbar
  • Next by thread: Re: [Core Data] mergeChangesFromContextDidSaveNotification: and thread safety
  • Index(es):
    • Date
    • Thread