It's now more than 5 months that I'm in Objective-C, I've also got my first app published in the App Store, but I still have a doubt about a core functionality of the language.
When am I supposed to use self
accessing iVars and when I'm not?
When releasing an outlet you write self.outlet = nil
in viewDidUnload, instead in dealloc
you write [outlet release]
. Why?
When you write self.outlet = nil
the method [self setOutlet:nil];
is called. When you write outlet = nil;
you access variable outlet
directly.
if you use @synthesize outlet;
then method setOutlet:
is generated automatically and it releases object before assigning new one if you declared property as @property (retain) NSObject outlet;
.
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