If I am writing my own custom init method what would I call be the appropriate call to super init be? I sometimes see it’s not just some super init method but something else, what’s the general rule for this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Objective-C classes may have multiple
initmethods. Usually, one of them is called the “Designated Initializer”, and is the one all the rest call.If you are subclassing, and creating an
initmethod with a different signature, you should call the superclass’ designated initializer (although calling any initializer of the superclass will work as well). The documentation for the classes will usually tell you what the designated initializer is.For instance, in
UITableViewCellthe designated initializer isinitWithStyle:reuseIdentifier:and is the one you should call if you subclass and create aninitmethod with a different signature.