On Nov 16, 2008, at 13:30, Arthur C. wrote:

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".
All right, but that does not cover the case of an object being added using the 'add' button linked to the array controller (which btw is bound to the correct managedObjectContext). Then you end up directly in awakeFromInsert, which at least should be OK if it is executed only once.

Using -[NSArrayController add:] as an action is often suitable only for the simplest cases. In your case, it would not be unreasonable to write your own action (in, say, the window controller) to create the object and insert it in the right place with the right characteristics.


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.
I'll check that. Undo is probably not the problem, we can trigger the error without doing an undo operation.

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

I'll do that, but as said, it's incomplete and the awakeFromInsert will still be needed...

It might also be worth putting a test in awakeFromInsert -- first check if the object has been assigned to a persistent store, and only assign if it has not.


_______________________________________________

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