I’m just wondering about self.view = nil in ARC.
- when set self.view = nil, self.view will be automatically released?
- When set self.view = nil, all the subviews will be automatically nil and released?
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.
1) Yes, assuming no other strong references exist to it (this is a very big if, and this can come up in unexpected places). The only thing guaranteed to happen is that its retain count will decrease by 1.
2) If your view is set to be deallocated by meeting the above conditions, then the subviews will automatically be released (their retain count will be decremented by 1). Assuming no other references exist to them (see point 1) they will be deallocated as well.
Everything depends on the number of strong references to an object. It is absolutely critical to understand that. An object will be deallocated if and only if its retain count reaches zero. You don’t directly control this as of ARC, but it is still very relevant.