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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to