Re: Accessors
Re: Accessors
- Subject: Re: Accessors
- From: Marcel Weiher <email@hidden>
- Date: Wed, 7 Aug 2002 20:14:32 +0200
On Wednesday, August 7, 2002, at 07:26 Uhr, Ondra Cada wrote:
On Wednesday, August 7, 2002, at 07:04 , Kevin Elliott wrote:
Also as an aside, man people have suggested that the following code
str= [thirdParty someObject];
some more code...
[str doSomething];
is inherently unsafe because the underlying value of str may be
changed.
Under the "classic" getter/setter model that's not true.
that model is:
someObject: (id) object { return myObject }
setSomeObject: (id) object
{
[myObject autorelease];
[object retain];
myObject= object;
}
It become true as soon as the "some more code..." uses nested
autorelease pools, and the setter happens to be inside one of them.
Another good reason not to use autorelease in "set" accessors either.
If you want it: retain it.
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.