• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Script Menu: Code generation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Script Menu: Code generation (From: Alexander von Below <email@hidden>)

  • Prev by Date: Script Menu: Code generation
  • Next by Date: Re: Question about dynamic and static libraries
  • Previous by thread: Script Menu: Code generation
  • Next by thread: Re: Script Menu: Code generation
  • Index(es):
    • Date
    • Thread