mongeta
mongeta

Reputation: 2301

popToRootViewControllerAnimated and dealloc all views

I have a UINavigationController that asks for some information and the user navigates until the end, once there, they can Accept or Cancel all the data that has been entered.

It doesn't matter wich option they choose, as they always will go to the first view using

[UINavigationController popToRootViewControllerAnimated:] 

The question is, how I can release/deallocate all the views ?

For example, they start for view 1 and the end is at view 8, once they go directly to the 1 from the 8, how I can release view 2,3,4,5,6,7,8 ?

thanks,

regards,

m.

Upvotes: 2

Views: 2208

Answers (1)

Vladimir
Vladimir

Reputation: 170839

Just allow navigation controller to handle memory for you - it retains controller pushed to its stack and releases them on remove. So if you do not take ownership of your controllers anywhere else they will be deallocated automatically after popped from navigation controller. Basically you should push controllers as follows:

SomeControllerType* controller = [[SomeControllerType alloc] init];
[navigationController pushViewController:controller animated:animated];
[controller release]; 

Upvotes: 3

Related Questions