• 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: Trying to understand -- please help...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to understand -- please help...


  • Subject: Re: Trying to understand -- please help...
  • From: Uli Kusterer <email@hidden>
  • Date: Wed, 21 May 2008 22:45:20 +0200

Am 21.05.2008 um 18:47 schrieb Peter Hudson:
Any initialiser with a "+" in front of it returns an autoreleased object


 NO! Several mistakes in this sentence:

1) "+" simply means that it is a method of the class, not of individual instances. It has NOTHING to do with whether the result is autoreleased, a shared singleton, or needs to be released by the caller.

2) An initializer is an "initXXX" method. By definition, you first request the memory for your object (using +alloc), then you have an instance, which you initialize by calling an initXXX method on it. Thus, initializers are inherently instance methods (with a "-"), and never have a "+" in front of them.

3) The Cocoa convention for deciding whether you, as the caller, should release an object depends on the name of the method. See Apple's docs for the details, as the list ops don't like people rephrasing the memory management rules (because usually people forget one or another rule).

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Trying to understand -- please help... (From: Peter Hudson <email@hidden>)

  • Prev by Date: Re: NSSecureTextField and paste
  • Next by Date: Re: Trying to understand -- please help...
  • Previous by thread: Re: Trying to understand -- please help...
  • Next by thread: Trying to understand -- please help...
  • Index(es):
    • Date
    • Thread