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!
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
James Fredrick
1,756 PointsviewDidDisappear method
Hi! I have been working on an iPhone app and was wondering if anybody could tell me how to properly use the viewDidDisappear method. I tried using the viewDidUnload but that is not supported in IOS 6.1. I also tried using viewDidDisappear like a normal viewDidUnload:
-(void)viewDidDisappear
{
[super viewDidDisappear];
}
1 Answer

Amit Bijlani
Treehouse Guest TeacherThere is no right or wrong usage of method viewDidDisappear
or viewWillAppear
. It's an event notification about your view controllers life cycle, so if there's any housekeeping you need to do as your view is no longer going to be visible then this is the method for it. Do you need to remove notification observers? Do you need to hide the keyboard? Do you need to stop audio from playing? Do you need stop something from downloading?

Mike Bronner
16,395 PointsThanks Amit! This helps clarify things for me as well. So while viewDidUnload is no longer relevant, viewDidDisappear provides opportunity to do your housekeeping. Thanks!
Mike Bronner
16,395 PointsMike Bronner
16,395 PointsHi Raphael, I had a similar question as well. See my findings here: https://teamtreehouse.com/forum/viewdidunload-no-longer-in-ios6-will-observers-remove-themselves?sort=newest&topic=iOS
I believe they apply here as well - you can forget about them if you are developing only for ios6.