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.
Here's an example I wrote which demonstrates two things:
Initializing a property, dot notation
Although the example focuses on initialization, dealloc
is susceptible to similar categories of problems. As one specific example: an object may partially resurrect itself in dealloc
, 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With