I'm new to storyboarding so the answer to this may be simplistic,
I've created a viewController in which a UITextField is present. My test is to transfer the data (text) from that text field into a viewController that is pushed onto the screen.
The coding that i have is as follows:
ViewController1.h -
#import <UIKit/UIKit.h>
#import "ViewController2.h"
@interface ViewController1 : UIViewController
@property (nonatomic, retain) IBOutlet UITextField *inputText;
@end
ViewController1.m
#import "ViewController1.h"
@implementation ViewController
@synthesize inputText;
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"showTextController"]) {
ViewController2 *vc2 = [segue destinationViewController];
vc2.selectedText.text = self.inputText.text;
}
}
@end
ViewController2.h -
#import <UIKit/UIKit.h>
@interface ViewController2 : UIViewController
@property (nonatomic, retain) IBOutlet UILabel *selectedText;
@end
ViewController2.m
#import "ViewController2.h"
@implementation ViewController2
@synthesize selectedText;
@end
The segue between viewController1 and 2 in storyboard is referred to as 'showTextController'.
Is this the correct coding for something so simple? Do i need to be using 'ViewDidLoad' method along with the prepareForSegue:sender method?