Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Mike Bronner
Mike Bronner
16,395 Points

viewDidUnload no longer in iOS6 - Will Observers Remove themselves?

Will registered observers automatically remove themselves in iOS6, as there is no viewDidUnload method in the template anymore?

Try to remove observers in the "viewWillDisappear" method (simply override it). Perhaps that may solve you issues.

Mike Bronner
Mike Bronner
16,395 Points

Hi Pavel, no I wasn't having any issues, just was unclear on the state of the function in iOS6. I simply left the function out and everything works as expected.

1 Answer

Jack Solomon
Jack Solomon
839 Points

You can add it in. Just start typing -(void)viewDidUnl... and type ahead will finish it off. Same with things like viewDidAppear. Now, other than viewDidLoad (which needs to be called every time, so Apple's left it in), you need to manually add the others in. It came out in xcode 4.6.3 (the one that came out with iOS 6).

Mike Bronner
Mike Bronner
16,395 Points

Hi Jack, thanks for your reply. This prompted me to do something I should have from the start: to look it up in the documentation. :) Turns out it is deprecated in iOS 6, where views are no longer purged in low-memory conditions, and this method is actually never called. So, if I'm targeting iOS 6 only, I no longer need it. :)