FROM : Uli Kusterer
DATE : Wed May 21 22:45:20 2008
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
DATE : Wed May 21 22:45:20 2008
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 mail archive

