Re: Script Menu: Code generation
Re: Script Menu: Code generation
- Subject: Re: Script Menu: Code generation
- From: j o a r <email@hidden>
- Date: Wed, 28 Dec 2005 23:34:54 +0100
On 28 dec 2005, at 23.17, Alexander von Below wrote:
the very useful Scripts menu of Xcode contains an item to create
accessor definitions.
While it is most certainly correct, I am wondering why it produces:
- (id) x {
return [[x retain] autorelease];
}
Is this not redundant? Why not just return x?
Some people seem to prefer that pattern:
<http://www.stepwise.com/Articles/Technical/2002-06-11.01.html/>
Personally, I find it to be wasteful and overly complex for no good
reason.
I guess that the setter code is a matter of preference. The
original code copies the new value, I have edited it to retain the
value.
In a *generic* setter method, copy is probably the correct and safe
operation. For immutable objects, copy is often replaced with retain
as an optimization:
<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/
Tasks/ImplementCopy.html#//apple_ref/doc/uid/20000049-999791>
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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