Re: Use of assign vs. copy for accessors in Garbage Collected app
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