Any problems with the following codes?
- (void) dealloc {
self.foo = nil;
}
Instead of
- (void) dealloc {
[_foo release];
_foo = nil;
}
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.
There are two reasons not to do the former:
If a subclass has overridden the setter, the release might not actually happen.
Using the setter might trigger a KVO notification and the observer will receive a notification from an object that technically doesn’t exist.
On the other hand, if you use ARC, you don’t need to do any of that.