When deallocing a refrence I’ve seen release and dealloc being used for example
-(void)dealloc { [foo release]; [nar dealloc]; [super dealloc]; }
My question is when is release to be used and when is dealloc to be used?
Thanks
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.
Never call
deallocexcept as[super dealloc]at the end of your class’sdeallocmethod. Thereleasemethod relinquishes ownership of an object. When a Cocoa object no longer has any owners, it may be deallocated — in which case it will automatically be sent adeallocmessage.If you’re going to program Cocoa, you need to read the Memory Management Guidelines. It’s incredibly simple once you get over the initial hump, and if you don’t understand what’s in that document, you’ll have lots of subtle bugs.