It's not necessary to match your initialisers with your class convenience constructor, especially in an ARC environment.
Take a look at the class documentation for UICollectionViewLayoutAttributes
as an example from Apple — it defines three different convenience constructors, but no initialisers other than -init
.
However, if you're not using ARC, there is a difference in memory management semantics: class constructors are expected to return autoreleased objects (and must be explicitly retained to transfer ownership to the caller). Or, more correctly, an object created by any method beginning with alloc
, new
, copy
, or mutableCopy
is owned by the caller (and thus any object that you are sending an init...
message). See Apple's memory management guide .
It's not necessary to match your initialisers with your class convenience constructor, especially in an ARC environment.
Take a look at the class documentation for UICollectionViewLayoutAttributes
as an example from Apple — it defines three different convenience constructors, but no initialisers other than -init
.
However, if you're not using ARC, there is a difference in memory management semantics: class constructors are expected to return autoreleased objects (and must be explicitly retained to transfer ownership to the caller). Or, more correctly, an object created by any method beginning with alloc
, new
, copy
, or mutableCopy
is owned by the caller (and thus any object that you are sending an init...
message).
It's not necessary to match your initialisers with your class convenience constructor, especially in an ARC environment.
Take a look at the class documentation for UICollectionViewLayoutAttributes
as an example from Apple — it defines three different convenience constructors, but no initialisers other than -init
.
However, if you're not using ARC, there is a difference in memory management semantics: class constructors are expected to return autoreleased objects (and must be explicitly retained to transfer ownership to the caller). Or, more correctly, an object created by any method beginning with alloc
, new
, copy
, or mutableCopy
is owned by the caller (and thus any object that you are sending an init...
message). See Apple's memory management guide .
It's not necessary to match your initialisers with your class convenience constructor, especially in an ARC environment.
Take a look at the class documentation for UICollectionViewLayoutAttributes
as an example from Apple — it defines three different convenience constructors, but no initialisers other than -init
.
However, if you're not using ARC, there is a difference in memory management semantics: class constructors are expected to return autoreleased objects (and must be explicitly retained to transfer ownership to the caller). Or, more correctly, an object created by any method beginning with alloc
, new
, copy
, or mutableCopy
is owned by the caller (and thus any object that you are sending an init...
message).