0

There's a UIViewController method -(void)viewDidUnload. I tried putting NSLog("unloaded"); in there to see when the view is unloaded, but nothing was printed to the console.

Where do I put my code, so that before a view unloads I can perform an action?

jscs
  • 63,694
  • 13
  • 151
  • 195

2 Answers2

5

If you read the viewDidUnload documentation, you see that it's related to low memory conditions and may be called to help with that. There is also a viewWillUnload that get's called before the view is released. It's also related to low memory.

If you're only interested in when the view is no longer seen, there are will/did disappear methods.

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57
0

Are you using storyboard or not?

Have you tried any of this methods

 -(void) viewWillUnload{}

or

-(void)viewWillDisappear:(BOOL)animated{}

If you are using storyboards the one that will that usually performs is viewWillDisappear.

marcos1490
  • 362
  • 3
  • 12