I am trying to pass textfield text from one controller to another controller so I can email it. I am following an example, but I must be missing some little details. Basically the goal is to pass data textfield text from enteryournamecontroller controller to option controller's nsstring. The nsstring's string variable is being returned null.
EnterYourNameController.h
@interface EnterYourNameController : UIViewController{
UITextField *textField;
id <EnterYourNameController> delegate;
}
@property (strong, nonatomic) NSString *stringEntered;
@property (strong, nonatomic) UITextField *textField;
@property (strong, nonatomic) id delegate;
EnterYourNameController.m
-(void)button{
stringEntered=textField.text;
((Options *) (self.delegate)).string = stringEntered;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
Options *vc = [storyboard instantiateViewControllerWithIdentifier:@"Options"];
[self.navigationController pushViewController:vc animated:YES];
}
options.h
@interface Options : UIViewController <MFMailComposeViewControllerDelegate> {
NSString *string;
}
@property (strong,nonatomic) NSString* string;
@end
option.m
NSString *emailBody = [NSString stringWithFormat:@"%@",string];