Re: Overridding -[NSPersistentDocument managedObjectContext]
Re: Overridding -[NSPersistentDocument managedObjectContext]
- Subject: Re: Overridding -[NSPersistentDocument managedObjectContext]
- From: Jerry Krinock <email@hidden>
- Date: Mon, 27 Oct 2008 13:44:05 -0700
On 2008 Oct, 27, at 12:32, Andy Lee wrote:
I don't see that instance variable. I only see a private
_managedObjectContext instance variable in the header, which you
wouldn't have access to anyway. Am I missing something?
Well, there NSPersistentDocument has -managedObjectContext and -
setManagedContext: methods. So, I presume that there is an instance
variable in there somewhere.
Should he also override -setManagedObjectContext:?
That's a whole'nother weird subject. Trying to get rid of super's
moc, I tried this:
NSPersistentDocument* doc = [[NSPersistentDocument alloc] init] ;
NSLog(@"After initing, moc = %@", [[doc managedObjectContext]
description]) ;
[doc setManagedObjectContext:nil] ;
NSLog(@"After nilling, moc = %@", [[doc managedObjectContext]
description]) ;
Here's what I got:
After initing, moc = <NSManagedObjectContext: 0x117190>
After nilling, moc = <NSManagedObjectContext: 0x117190>
:{
My 2 cents: this seems like a brittle design -- it expects the
overrider to know that the superclass never uses the ivar directly
except in accessors, and it expects the implementer of the base
class to remember never to use the ivar directly...
Yes, the more I think about this, the less I like it. I'm going to
step back here and try to avoid overriding that moc.
In any case, I think the documentation could be clearer and I'll
send feedback to that effect.
Great!
_______________________________________________
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