First of all, as I understand it, init in Objective-C
, functionally is similar to a constructor in Java
, as it is used to initialize instance variables and prepare a class to do some work. Is this correct?
I understand that NSObject
implements init
and as such it does not need to be declared in any .h
files.
But how about custom implementation of init for a given class, for example:
(id) initWithName:(NSString *) name
Should declaration like this be listed as part of .h
, or it is not necessary? Is it done by convention or is there any other reasoning?