Re: Synthesised properties and additional actions
Re: Synthesised properties and additional actions
- Subject: Re: Synthesised properties and additional actions
- From: Dave DeLong <email@hidden>
- Date: Sat, 18 Jun 2011 22:16:29 -0700
The instance variable is synthesized as well and has the same name as the property, so you should use that:
-(void)setFoo:(id)newFoo {
if (foo != newFoo) {
[foo release];
foo = [newFoo retain];
[self doSomethingElseAsWell];
}
}
Dave
On Jun 18, 2011, at 10:12 PM, Graham Cox wrote:
> If I synthesize a property, is it possible to also directly invoke some other code when that property is set (other than the usual KVO)? That is, I need to do something like:
>
>
> @synthesize foo;
>
>
> - (void) setFoo:(id) newFoo
> {
> self.foo = newFoo;
>
> [self doSomethingElseAsWell];
> }
>
>
> Is this kind of thing possible? It looks to me as if the self.foo = line will incur an infinite loop. But if the property is synthesized, to what would I assign the new value?
>
> --Graham
>
>
> _______________________________________________
>
> 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
_______________________________________________
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