• 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
Retrieving Master from Slave
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Retrieving Master from Slave


  • Subject: Retrieving Master from Slave
  • From: Mike Rossetti <email@hidden>
  • Date: Mon, 28 Jan 2008 22:17:25 -0700

The following refers to a Core Data document-based application with a 'Master' entity that has a many-to-one relationship to a 'Slave' entity. The Master is the root entity of the document. I', building to 10.5 and my implementation is nearly identical to the one demonstrated in the "NSPersistentDocument Core Data Tutorial".

At the point of my question, the document object has been retrieved from disk and I am editing by adding a new Slave to the existing Master entity. In Slave's awakeFromInsert I would like to retrieve the Master and initialize some attributes in the new Slave entity using attributes from the Master.

I'm a little confused as to how retrieve a reference to the Master. I originally thought that I could just use self.master or [self valueForKey:@"master"] but the 'master' member is nil. Re-reading the "Adopting the Mediator Pattern" in the "NSPersistentDocument Core Data Tutorial" made me try fetching the Master using an executeFetchRequest, which works. The tutorial suggests that simply retrieving the master from the relevant object controller is even more appropriate but makes me wonder how the slave is supposed to get a reference to the master entity object controller.

This seems like a lot of work and I can't help but think that there is a simpler way to retrieve the 'master' object.

Any suggestions?  Examples?

Thanks,
Mike

_______________________________________________

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


  • Prev by Date: Re: Running process as root from Cocoa
  • Next by Date: Re: keeping view's bounds fixed
  • Previous by thread: Re: keeping view's bounds fixed
  • Next by thread: Adjusting line spacing on a NSMutableString
  • Index(es):
    • Date
    • Thread