init
is not for creating an instance; that's alloc
's job (and alloc
is a class method).
init
is for setting up the created instance. It needs access to the new instance's ivars, and must be an instance method.
Question
Why is the init
method not a class method? I mean init
's method body starts with an -
.
Methods starting with -
are instance methods as far as I know, but obviously we want to create an instance.
Solution
init
is not for creating an instance; that's alloc
's job (and alloc
is a class method).
init
is for setting up the created instance. It needs access to the new instance's ivars, and must be an instance method.