• 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: Addressing Relationships in awakeFromInsert
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Addressing Relationships in awakeFromInsert


  • Subject: Re: Addressing Relationships in awakeFromInsert
  • From: August Trometer <email@hidden>
  • Date: Wed, 10 Aug 2005 15:31:11 -0500

Thanks for the response!

At no point am I setting the Master object -- this should be done automatically. I'm assuming (maybe incorrectly?) that because of the inverse Relationship set up between the Master and Detail Entities that the "master" Relationship in my Detail object automatically points back to the Master object that it's created within.

So on awakeFromInsert, I'm also assuming that the relationship information is already set. Perhaps this is where my error is? If so, when and where does this information get set?

And as far as data redundancy, I agree -- what I'm trying to do is set some default values, based on data in the Master object, which the user can then change if desired.


-- August



On Aug 10, 2005, at 3:12 PM, Jim Correia wrote:

On Aug 10, 2005, at 4:01 PM, August Trometer wrote:


I've got 2 Entities set up in a master-detail configuration. They have inverse Relationships.

I've subclassed the Detail Entity and overridden the awakeFromInsert method to add some default values (date added, etc.). However, when I try to address the owner or Master via valueForKeyPath, I get a Null return.

Here's a snippet from the Detail Entity:

- (void) awakeFromInsert
{
    [super awakeFromInsert];

[self setValue:[NSDate date] forKey:@"dateCreated"]; // works fine
[self setValue:[self valueForKeyPath:@"master.createdBy"] forKey:@"createdBy"]; // sets the value to NULL
}


I'm sure I'm missing something here -- it does seem to be the best place for this sort of default setting -- but I can't seem to figure out how to address the Master object. I've also tried simply NSLogging [self valueForKeyPath:@"master"] and it, too, returns Null.


awakeFromInsert is sent to your object just after it is created. When do you set the value for master?


Did you write an accessor for setMaster and also sync the createdBy value there?

(It is hard to tell from your limited example, but if self.createdBy and master.createdBy are supposed to always be the same value, it may make sense to remove the redundant information in one place so that they never have the opportunity get get out of sync.)

Jim


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Addressing Relationships in awakeFromInsert
      • From: mmalcolm crawford <email@hidden>
    • Re: Addressing Relationships in awakeFromInsert
      • From: Jim Correia <email@hidden>
References: 
 >Addressing Relationships in awakeFromInsert (From: August Trometer <email@hidden>)
 >Re: Addressing Relationships in awakeFromInsert (From: Jim Correia <email@hidden>)

  • Prev by Date: WebServices problem
  • Next by Date: Re: Question about Threading
  • Previous by thread: Re: Addressing Relationships in awakeFromInsert
  • Next by thread: Re: Addressing Relationships in awakeFromInsert
  • Index(es):
    • Date
    • Thread