Sometimes I set objects to nil after releasing them to avoid crashes due to unexpected messages sent to dealloc‘d objects.
Why doesn’t the Objective-c runtime do this automatically when an object is finally dealloc‘d?
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.
Because pointers are passed by value and not reference. All
deallocgets is a local copy of the pointer; any changes it makes are discarded. Same goes for C’sfreeand C++’sdelete.