Remember we don't know the structure of your application. In the posts above you mention a Home button and Home tab, so it is unclear what you mean by pressing Home. Lots of design patterns would work. Here is an one easy example. I recommend you build a simple test project like this and play around with it to see how it works, then decide how to revise your real project.
Assume: Storyboard with push segues between view controllers. Each view controller shows the current value in a text field, and optionally has buttons Plus 0, Plus 1, and Restart. All segues use identifier ShowNextStep. The segues are from VC to VC, not from button to VC, because they will be programmatically invoked.
Navigation Controller > Step 1 View Controller > Step 2 View Controller > Step 3 View Controller
[AppDelegate.h]
@propertyNSInteger currentValue; // persist currentValue on the application delegate.
[AppDelegate.m]
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// initialize on application launch
self.currentValue = 0;
returnYES;
}
All three view controllers use the same class StepViewController. This allows you to add an arbitrary number of view controllers to the storyboard without creating new classes or writing any code.
[StepViewController.h]
#import <UIKit/UIKit.h>
@interface StepViewController : UIViewController
@property (weak, nonatomic) IBOutletUITextField *currentValueField;
// actions don't need to be hooked up on every view controller
- (IBAction)plus0ButtonClick:(id)sender;
- (IBAction)plus1ButtonClick:(id)sender;
- (IBAction)restartButtonClick:(id)sender;
@end
[StepViewController.m]
#import "StepViewController.h"
#import "AppDelegate.h"
@interfaceStepViewController ()
@end
@implementation StepViewController
- (void)viewDidLoad
{
[superviewDidLoad];
// show currentValue
NSInteger currentValue =((AppDelegate *)([UIApplication sharedApplication].delegate)).currentValue;
self.currentValueField.text = [NSString stringWithFormat:@"%d", currentValue];
}
- (IBAction)plus0ButtonClick:(id)sender {
// no value change, navigate to next step
[selfperformSegueWithIdentifier:@"ShowNextStep"sender:self];
}
- (IBAction)plus1ButtonClick:(id)sender {
// change value, navigate to next step
NSInteger currentValue = ((AppDelegate *)([UIApplication sharedApplication].delegate)).currentValue;
((AppDelegate *)([UIApplication sharedApplication].delegate)).currentValue = currentValue + 1;
[selfperformSegueWithIdentifier:@"ShowNextStep"sender:self];
}
- (IBAction)restartButtonClick:(id)sender {
// reset value, navigate to first step (won't work if modal segue)
((AppDelegate *)([UIApplicationsharedApplication].delegate)).currentValue = 0;
[self.navigationControllerpopToRootViewControllerAnimated:YES];
}
@end
If want to totally control navigation with your buttons, hide the navigation bar.
self.navigationController.navigationBarHidden = YES;
If you want currentValue to refresh on the root view controller (Step 1), add a handler for viewWillAppear. The root view controller is not reloaded unless iOS terminates the app so viewDidLoad won't work. I think you want the root view controller to always reset to the initial value, so you probably don't need to do this.