views:

142

answers:

1

Hello,

I'm trying to set up an in app purchase and once the purchase has been made I need to reset the app to its initial launch state. I'm wondering if there is a way to dealloc all the view controllers inside of each navigation controller and reload the initial view that is displayed when the app launches.

Thanks in advance!

+1  A: 

You can just

[self.navigationController setViewControllers:nil animated:NO];

(probably works, although not tested) however it is probably more useful to use:

[self.navigationController popToRootViewControllerAnimated:NO];

It is up to you to keep track of your navigation controllers, and to restore your starting view.

Paul Lynch
Hi, thanks for the info. If I set all my view controllers to nil is that going to create some memory leaks? It seems like i should maybe call dealloc on them somehow. Thanks
jmurphy
They are passed in as an NSArray, which retains it's contents and releases them when released itself, which is the responsibility of the nave controller. You shouldn't have any retains on the view controllers themselves, unless you need to refer to them elsewhere. PS we never call dealloc directly.
Paul Lynch