• 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
Re: Two Applications Sharing Same Core Data Database
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Two Applications Sharing Same Core Data Database


  • Subject: Re: Two Applications Sharing Same Core Data Database
  • From: Nick Zitzmann <email@hidden>
  • Date: Thu, 07 Apr 2011 16:38:56 -0600

On Apr 7, 2011, at 4:24 PM, Carter R. Harrison wrote:

> I really appreciate all of your help.  I gave your suggestion a shot and I've run into problems.  Here's what happens.
>
> 1. I create a new NSManagedObject in my main application.  It gets inserted into the context.
> 2. I save the context.  I can see the persistent store update in a text editor (its an XML store).
> 3. I send a distributed notification with the NSManagedObject's ObjectID.
> 4. My background application consumes the notification and uses the object ID to get an NSManagedObject (using [NSManagedObjectContext objectWithID:].  This produces an NSManagedObject that is a fault.
> 5. I try to fire the fault by using [NSManagedObject valueForKey:].
> 6. Step 5 results in an exception "CoreData could not fulfill a fault for '0x1001029e0 <x-coredata://BB194166-B2FB-48ED-8177-E66F95B6CA3A/Alert/p118>'"
>
> I'm not sure I understand why this is happening.  If the object is truly a fault then shouldn't Core Data go back to the persistent store to find the object?

I think I've seen this before... Try calling sync() at the top of your notification handler. That will force external database changes to be written to disk.

If that doesn't work, then you may need to fetch the object from the context using some identifier other than the object ID. We do this in our products that share a database, and it works for us when a helper app receives a notification from the master app that a record has been added/updated/deleted.

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

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: Two Applications Sharing Same Core Data Database
      • From: "Carter R. Harrison" <email@hidden>
References: 
 >Re: Two Applications Sharing Same Core Data Database (From: "Carter R. Harrison" <email@hidden>)

  • Prev by Date: Re: Two Applications Sharing Same Core Data Database
  • Next by Date: Re: Two Applications Sharing Same Core Data Database
  • Previous by thread: Re: Two Applications Sharing Same Core Data Database
  • Next by thread: Re: Two Applications Sharing Same Core Data Database
  • Index(es):
    • Date
    • Thread