Re: Overridding -[NSPersistentDocument managedObjectContext]
Re: Overridding -[NSPersistentDocument managedObjectContext]
- Subject: Re: Overridding -[NSPersistentDocument managedObjectContext]
- From: Andy Lee <email@hidden>
- Date: Mon, 27 Oct 2008 14:44:56 -0400
On Oct 27, 2008, at 1:49 PM, Jerry Krinock wrote:
- (NSManagedObjectContext*)managedObjectContext {
if (![super managedObjectContext]) {
// Create a new MOC...
// Oops, sorry, this branch will never execute.
}
return [self managedObjectContext] ;
}
Won't this lead to infinite recursion? And why are you calling [super
managedObjectContext] if the intent is to create your own MOC? It
looks like this should be something like:
- (NSManagedObjectContext*)managedObjectContext {
NSManagedObjectContext* moc = /* ... create your own MOC ... */;
[self setManagedObjectContext:moc];
return moc;
}
Or alternatively, if your intent is to use the inherited behavior but
do some additional stuff to the MOC:
- (NSManagedObjectContext*)managedObjectContext {
NSManagedObjectContext* moc = [super managedObjectContext];
// ... Do custom stuff to moc ...
return moc;
}
[Disclaimer: I don't know Core Data, I'm just going by a quick look at
the docs and a guess at your possible intentions.]
--Andy
_______________________________________________
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