One would think I can easily find an answer to this question, and perhaps I missed it, but here goes.
My app contains a few views of which the main view displays a bunch of information it progressively collects from a user, the mic and and the camera through the other views. It is all supposed to end with one big climactic "submit button." At that point the data gets safely stored (currently in an sql database... but that's another story).
Once that is done, I want the whole process to start over which means reinitializing the view to a virgin state. In android, I can throw a new intent and destroy the old one.
I gather I'm supposed to start with the app delegate (see code below). Now the question is, where do I go from here?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.mainViewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
self.window.rootViewController = self.mainViewController;
self.mainViewController.managedObjectContext = self.managedObjectContext;
[self.window makeKeyAndVisible];
return YES;
}
So after a fair share of digging around, and trial and error. I found something that works the way I want it to.
I created a special function in the app delegate which executes the following:
Then from main view controller, I call that function
Easy as pie...