0

viewDidUnload is not allowed at ios6,so how to Compatibility viewDidUnload and didReceiveMemoryWarning to call. i need

- (void)viewDidUnload{

self.listArr=nil;

[super viewDidUnload];
}  




 - (void)didReceiveMemoryWarning
{

[super didReceiveMemoryWarning];
float sysVer =[[[UIDevice currentDevice] systemVersion] floatValue];
if (sysVer>= 6.0f){
    if([self isViewLoaded] && !self.view.window){
        self.listArr=nil;

        self.view = nil;
    }
}

 NSLog(@" BrowseComment didReceiveMemoryWarning");

}

or only use the follow code at ios5 and ios6

- (void)didReceiveMemoryWarning
{

[super didReceiveMemoryWarning];

    if([self isViewLoaded] && !self.view.window){
        self.listArr=nil;

        self.view = nil;
    }


 NSLog(@" BrowseComment didReceiveMemoryWarning");

}

pengwang
  • 19,536
  • 34
  • 119
  • 168
  • Please refer to this [http://stackoverflow.com/questions/12674268/ios-6-viewdidunload-migrate-to-didreceivememorywarning][1] [1]: http://stackoverflow.com/questions/12674268/ios-6-viewdidunload-migrate-to-didreceivememorywarning – Mark Kryzhanouski Feb 19 '13 at 11:44

2 Answers2

0

In iOS 6, the viewWillUnload and viewDidUnload methods of UIViewController are now deprecated. If you were using these methods to release data, use the didReceiveMemoryWarning method instead. You can also use this method to release references to the view controller’s view if it is not being used.

The codes currently using in viewDidUnload should be moved into didReceiveMemoryWarning. It will work on both iOS5 & iOS6 also. Actually before this change happens the viewDidUnload method is get invoked only when application did receive memory warning. So viewDidUnload does not have any particular significance. So they deprecate it.

Anil Varghese
  • 42,757
  • 9
  • 93
  • 110
0

From iOS 6 onwards the viewDidUnload and viewWillUnload have no role.

So if you need to handle the memory warnings, do it in the didReceiveMemoryWarning

Midhun MP
  • 103,496
  • 31
  • 153
  • 200