Hi, During init time (awakeFromNib), I build a list of objects into a mutable dictionary, keyed by an [NSManagedObject objectID]. I load the objects up, then check to see if there are any NSManagedObjects in the managedObjectContext with the same name as the objects I load during init time. If they aren't there, I create a new NSManagedObject. Then I put my object in the dictionary, keyed by the NSManagedObject I either found or created.
This procedure works fine for new documents. But when I am loading from a file, I can't find any init-time method that can access the fully loaded managedObjectContext. I have overrided many methods trying to find where the NSPersistentDocument is fully loaded, the one that is documented for NSDocument is called "initWithContentsOfURL" - (id)initWithContentsOfURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError { self = [super initWithContentsOfURL:absoluteURL ofType:typeName error:outError]; NSLog(@"the context is size %d during initWithContentsOfURL", [[[self managedObjectContext] registeredObjects] count]); return self; } this returns a context of size 0, other methods I have tried include awakefromnib, configurePersistentStoreCoordinatorForURL, windowControllerDidLoadNib, etc. All return 0 for [[[self managedObjectContext] registeredObjects] count]. I have referred the mailing list archive message: http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00993.html but this doesn't solve the problem. Also - I am using 10.4 (I think the only difference here is the new configurePersistentStoreCoordinatorForURL method) Thanks in advance -- /andrew - - http://www.andrewbeckmusic.com/ - - _______________________________________________ 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]