Prior to iOS 6, we were supposed to
- (void)viewDidUnload {
self.someDelegate = nil;
[super viewDidUnload];
}
Now that viewDidUnload is deprecated, where do we set our delegates to nil? 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.
Views are no longer unloaded when receiving a memory warning in iOS6. So the view is never unloaded on such cases and
viewDidUnloadis never called in iOS6.If you really want to mimic the old behavior (unloading the view upon receiving a memory warning) you now have to implement this behavior in the
didReceiveMemoryWarningmethod of your view controller, after testing that theself.view.windowproperty is nil (meaning the view is not on screen anymore, thus will be “unloaded”, meaning that you are in the same situation as the oldviewDidUnloadcase).But note that if you use ARC and iOS5+, you generally won’t need to set your delegate to
nilanymore, thanks to theweakproperty attribute and the Zeroing-Weak-References mechanism that automatically reset weak variables and properties tonilif the object they are pointing to does not exist anymore (thus avoiding dangling pointers).[EDIT] And as explained by @Martin R in the comments, views are not unloaded anymore when receiving a memory warning in iOS6, so you won’t have to manage this case of receiving a memory warning and think about releasing your delegate there as this use case won’t occur anymore in iOS6.