• 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: Jim Correia <email@hidden>
  • Date: Wed, 10 Aug 2005 16:12:28 -0400

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: August Trometer <email@hidden>
References: 
 >Addressing Relationships in awakeFromInsert (From: August Trometer <email@hidden>)

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