//
//  Page1Controller.h
//  MultiScenes
//
//  Created by UEC on 26/9/16.
//  Copyright (c) 2016年 Unisoft. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface Page1Controller : UIViewController

@end

____________________________
//
//  Page1Controller.m
//  MultiScenes
//
//  Created by UEC on 26/9/16.
//  Copyright (c) 2016年 Unisoft. All rights reserved.
//

#import "Page1Controller.h"
#import "Page2Controller.h"
#import "Page3Controller.h"

@interface Page1Controller ()

@end

@implementation Page1Controller

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

// When you move to Page2 or Page3, the following method called
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([[segue identifier]isEqualToString:@"pathToPage2"]){
        NSLog(@"Go TO Page 2");
        Page2Controller *page2 = (Page2Controller*)[segue destinationViewController];
        page2.receivedDataPage2 = @"Peter from Page 1";
    }
    if([[segue identifier]isEqualToString:@"pathToPage3"]){
        NSLog(@"Go TO Page 3");
        Page3Controller *page3 = (Page3Controller*)[segue destinationViewController];
        page3.receivedDataPage3 = @"Mary from Page 1";
    }

}

-(IBAction)unwindViewController:(UIStoryboardSegue *)segue{
  NSLog(@"Unwind method is called");

}

@end

_________________

//
//  Page2Controller.h
//  MultiScenes
//
//  Created by UEC on 26/9/16.
//  Copyright (c) 2016年 Unisoft. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface Page2Controller : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *page2RLabel;

@property NSString *receivedDataPage2;

@end
______________
//
//  Page2Controller.m
//  MultiScenes
//
//  Created by UEC on 26/9/16.
//  Copyright (c) 2016年 Unisoft. All rights reserved.
//

#import "Page2Controller.h"

@implementation Page2Controller

-(void)viewDidLoad{

    self.page2RLabel.text = self.receivedDataPage2;
}

@end
___________________________
//
//  Page3Controller.h
//  MultiScenes
//
//  Created by UEC on 26/9/16.
//  Copyright (c) 2016年 Unisoft. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface Page3Controller : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *page3RLabel;

@property NSString *receivedDataPage3;
@end

__________________________
//
//  Page3Controller.m
//  MultiScenes
//
//  Created by UEC on 26/9/16.
//  Copyright (c) 2016年 Unisoft. All rights reserved.
//

#import "Page3Controller.h"

@implementation Page3Controller
-(void)viewDidLoad{
    
    self.page3RLabel.text = self.receivedDataPage3;
}
@end

________________