I am doing some reading about the Memory Management and they do not recommend to use accessor methods in initializer method.
Question: why should not we use accessor methods in initializer method?
I am confusing about it.
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.
Here’s an example I wrote which demonstrates two things:
Initializing a property, dot notation
Although the example focuses on initialization,
deallocis susceptible to similar categories of problems. As one specific example: an object may partially resurrect itself indealloc, and reference count imbalances become a potential danger.Briefly, you want to focus on correct initialization and cleanup of the data your objects need — rather than the behavioral concerns/influence of your objects through any subclasses.
More reading:
Why myInstance = nil instead of self.myInstance = nil?
Should I refer to self.property in the init method with ARC?
Best way to set a retained property to a newly created object