View unloading woes


Hello Forum,

I’m trying to understand why my timeView has not been unloaded after executing this bit of code:

- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; if([self isViewLoaded] && ![[self view] window]) { NSLog(@"Unloading TimeViewController's subviews"); [self setView:nil]; NSLog(@"view = %@", [self view]); NSLog(@"timeLabel = %@", timeLabel); } }

Specifically it logs “view = <UIView: 0x718a680;[…]>” in the console. Shouldn’t it say “nil” after [self setView:nil]?

I’m sure I’m missing something obvious, thanks for a push in the right direction :wink:


If you’re using iOS 6.0 or higher (In the simulator or on device)

  • views do not get unloaded when they get low memory warning messages,


I also struggled at this point. For more explanation (if not much more), there is the video of an WWDC2012 session number 236: The evolution of view controllers on iOS.


Awesome, answered my question as well.

Love this forum for going along with the book.