• 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: Core data save error with multiple persistent stores
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core data save error with multiple persistent stores


  • Subject: Re: Core data save error with multiple persistent stores
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 16 Nov 2008 12:25:51 -0800

On Nov 16, 2008, at 12:02, Arthur C. wrote:

I take care that every object instance gets inserted into the right managedObjectContext, by using [NSEntityDescription insertNewObjectForEntityForName: ...]. And it gets assigned to the right persistent store by using

- (void) awakeFromInsert
{
...
[managedObjectContext assignObject:self toPersistentStore: [persistentStoreCoordinator persistentStoreForURL: url]];
}.
There are no relationships between objects in different persistent stores, as it should be.


This seems to work OK on one system, but leads to a strange error on two other systems (for the same program).

When a change has been made to the Core Data objects (e.g. adding an instance), the 'save' action of the managedObjectContext gives an exception (no error screen) saying 'can't reassign object to a different store once it has been saved'.
This means the Core Data stack cannot be saved anymore, which is of course a serious problem.


Do you know what causes this error? Do I need to use a different setup for the managedObjectContext - persistentStoreCoordinator - persistentStores system?

The example in the documentation:

http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdCreateMOs.html#/ /apple_ref/doc/uid/TP40001654-SW2

does the assignment immediately after the "insertNewObjectForEntityForName" call, not in "awakeFromInsert".

I'm wondering if undo is what's causing your problem. If not undo, then some other circumstances that leads to "awakeFromInsert" being called when the object is not really brand-new.

Have you tried doing it the way Apple's example shows?


_______________________________________________

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


References: 
 >Core data save error with multiple persistent stores (From: Arthur C. <email@hidden>)

  • Prev by Date: Re: NSView positioning problems
  • Next by Date: Using NSDateFormatter on NSPopUpButton in IB
  • Previous by thread: Core data save error with multiple persistent stores
  • Next by thread: RE: Core data save error with multiple persistent stores
  • Index(es):
    • Date
    • Thread