Search code examples
iosobjective-cuiviewuinavigationcontrollerpoptoviewcontroller

popToViewController and memory management


I have three view controllers pushed in navigationcontroller on the third one i used the statement

[self.navigationController popToViewController:(Main_View*) mainViewObj animated:YES];

It takes me directly to my specified controller say first. I have done some coding to remove objects from an NSMutableDictionary in viewWillDisappear method in all view controllers, i tried debugging using break points but it never comes to viewWillDisappear, it takes me directly to Main_View. Should i be worried about removing objects from dictionary or releasing it?


Solution

  • The viewWillDisappear: method is not called for the other view controllers because they have already disappeared when you were pushing view controllers on top of them. So basically, viewWillDisappear: was already called for them at an earlier point. It wouldn't make sense to call it again, because they weren't visible in the first place.