Consider I have a property named sampleObject.
In dealloc method, which should be the best way to manage memory?
Option 1:
self.sampleObject = nil; //This will release the sampleObject and set it to nil
This is equivalent to
[sampleObject release];
sampleObject = nil;
Option 2:
Explicitly releasing an object and setting it to nil
[sampleObject release];
sampleObject = nil;
In my opinion, both would achieve the same results? Please Share your views.
Regards,
Krishnan
in a dealloc method, the class is never used again so setting retained resources/properties to nil is just not required. Sending release is the best option and avoids unnecessary code.