Here is a trick I saw somewhere else that might do what you need. On the other 
hand, i'm still learning cocoa myself so it may have drawbacks that I'm unaware 
of.

Create a private property (like internal_foo below) to handle memory. Then have 
a public property to do the other stuff. So users of the class access the 
property with "foo" and you get synthesized memory management with internal_foo.

Sent from my iPad

On Jun 18, 2011, at 10:12 PM, Graham Cox <graham....@bigpond.com> 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 internal_foo;
> 
> 
> - (void)        setFoo:(id) newFoo
> {
>      self.internal_foo = newFoo;
> 
>     [self doSomethingElseAsWell];
> }
> 
-(id) foo
{
    return self.internal_foo;
}
> 
> 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 (Cocoa-dev@lists.apple.com)
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/eeyore%40monsterworks.com
> 
> This email sent to eey...@monsterworks.com
> 
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to