• 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: Use of assign vs. copy for accessors in Garbage Collected app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use of assign vs. copy for accessors in Garbage Collected app


  • Subject: Re: Use of assign vs. copy for accessors in Garbage Collected app
  • From: Jonathon Mah <email@hidden>
  • Date: Thu, 29 Nov 2007 01:12:40 +1030

Hi Rick,

On 2007-11-28, at 23:59, Rick Hoge wrote:

Sometimes it's just necessary to refer to another object that may change. Typically I register key-value observers for the properties of the other object I'm interested in (e.g. [otherObject addObserver:self forKeyPath:@"someIvar" options:0 context:nil];) and handle change notifications in

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject: (id)object change:(NSDictionary *)change context:(void *)context


You can also do something like:
[self bind:@"othersIvar"
      toObject:otherObject
      forKeyPath:@"someIvar"
      options:0];

and handle your changes in your own -(void)setOthersIvar:(id)x method. The advantage of this is that the setter is called as soon as you call the bind:... method, and the disadvantage is that you have to maintain a local reference to that value (or at least you *should*).



Jonathon Mah
email@hidden


_______________________________________________

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: 
 >Use of assign vs. copy for accessors in Garbage Collected app (From: Rick Hoge <email@hidden>)
 >Re: Use of assign vs. copy for accessors in Garbage Collected app (From: Shawn Erickson <email@hidden>)
 >Re: Use of assign vs. copy for accessors in Garbage Collected app (From: Rick Hoge <email@hidden>)

  • Prev by Date: Re: Adding HUD context pannel to rows within NSOutlineView
  • Next by Date: Re: CALayer - delegate not being called?
  • Previous by thread: Re: Use of assign vs. copy for accessors in Garbage Collected app
  • Next by thread: Re: Use of assign vs. copy for accessors in Garbage Collected app
  • Index(es):
    • Date
    • Thread