Re: object Properties released or autoreleased?
Re: object Properties released or autoreleased?
- Subject: Re: object Properties released or autoreleased?
- From: Andreas Grosam <email@hidden>
- Date: Thu, 15 Jan 2009 13:06:31 +0100
On 14.01.2009, at 19:19, Andy Lee wrote:
On Jan 14, 2009, at 12:56 PM, Memo Akten wrote:
it is sent a release. if you want to autorelease you can create
your own setter:
- (void) setThing: (NSObject*) newThing {
[thing autorelease];
//or
[thing release]; (default)
thing = [newThing retain];
}
Memo might have meant this code to give a general idea, not to be
taken verbatim, but for the record: if you choose the release
option, you need to handle the case where thing == newThing on
entry. Otherwise you run the risk of dealloc'ing the object
prematurely.
hm, this would mean
@property (retain) NSObject* thing;
...
self.thing = self.thing;
that the assignment will not be implemented propperly if the setter
has been @synthesized, and the possible call of -dealloc/-finalize
method will cause undefined behavior.
If the language and compiler cannot handle basic patterns correctly,
why do we have @synthesize at all?
I haven't tested it yet, but I strongly believe it will work exactly
as we would implement these basic patterns ourself. Please, can
anybody confirm this?
Where is the standardized formal language spezification, anyway?
(rhetoric question).
Andreas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden