Remove data from UIViewController when removing it from the Navigation Stack

By : Marko
Source: Stackoverflow.com
Question!

I've built an order process application which has about 5-6 Views that capture data and save it to a database.

Now once the order is complete, I'm using PopToRootViewController to return to the first View but I'd like the data on the other Views to disappear (basically start a new order).

At the moment if I open the view again the data from the previous 'order' is still there...

So how do I dispose of all the UIViewControllers once an order is complete?

By : Marko


Answers

If your certain they're being released (which you could check the retain counts to see if it crashes), then maybe on each view controllers viewWillAppear method you could re-init the data. But that's more of a work around than understanding what's wrong.



It depends entirely on how you're managing your view controllers. It sounds like you should be releasing them after each order, and creating new ones for the next order. Instead, it sounds like you're keeping them around in your app or root level controller.

By : antsyawn


This video can help you solving your question :)
By: admin