• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Overridding -[NSPersistentDocument managedObjectContext]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Overridding -[NSPersistentDocument managedObjectContext] (From: Jerry Krinock <email@hidden>)
 >Re: Overridding -[NSPersistentDocument managedObjectContext] (From: Ron Lue-Sang <email@hidden>)
 >Re: Overridding -[NSPersistentDocument managedObjectContext] (From: Andy Lee <email@hidden>)

  • Prev by Date: Core Data Questions--Relationships, UUIDs, and Dirty States
  • Next by Date: Re: Problems when putting a window between desktop and desktop icons
  • Previous by thread: Re: Overridding -[NSPersistentDocument managedObjectContext]
  • Next by thread: NSTableView Questions
  • Index(es):
    • Date
    • Thread