• 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
Handling NSManagedObjectContextDidSaveNotification from different threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Handling NSManagedObjectContextDidSaveNotification from different threads


  • Subject: Handling NSManagedObjectContextDidSaveNotification from different threads
  • From: Rick Mann <email@hidden>
  • Date: Tue, 10 Aug 2010 13:55:18 -0700

We have an app that uses a "main" NSManagedObjectContext (MOC) for all UI-related work, and has background threads that add and update data via their own dedicated MOCs. When they call -save: on their MOC, the "main" MOC gets the NSManagedObjectContextDidSaveNotification and calls -mergeChangesFromContextDidSaveNotification:.

The problem is, this actually happens on the thread that called -save:, not on the main thread. We're seeing occasional crashes, and suspect that it is due to this problem. However, I didn't see anything in the docs that said we had to call -save: from the main thread, or take any special steps when handling that notification.

Did I just overlook something, or should this work safely always? It seems like the latter is unlikely, since two threads could be accessing a MOC simultaneously.

Thanks,
Rick

_______________________________________________

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: Handling NSManagedObjectContextDidSaveNotification from different threads
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: printPanelDidEnd:returnCode:contextInfo: variable isn't updated
  • Next by Date: Re: Math.h functions with CGFloat
  • Previous by thread: Re: printPanelDidEnd:returnCode:contextInfo: variable isn't updated
  • Next by thread: Re: Handling NSManagedObjectContextDidSaveNotification from different threads
  • Index(es):
    • Date
    • Thread