I'm trying this
SignUpViewController *userEmail=[[SignUpViewController alloc] init];
userEmail.emailAddress.text=email;
but is not working.
I'm trying this
SignUpViewController *userEmail=[[SignUpViewController alloc] init];
userEmail.emailAddress.text=email;
but is not working.
It seems like emailAddress (assuming UITextfeild) is not allocated properly when you called
SignUpViewController *userEmail=[[SignUpViewController alloc] init];
So, it is nil at the point of init.
Better way to do would be, added one public property in SignUpViewController of NSString. Save the value in that property. Like Below
SignUpViewController *userEmail=[[SignUpViewController alloc] init];
userEmail.emailString=email;
in SignUpViewController.h file add
@property (nonatomic, strong) NSString *emailString;
in SignUpViewController.m file in view did load
- (void)viewDidLoad{
//if you have not used nib or stroyboard init you textfield first
emailAddress.text=emailString;
}
Move your emailAddress @property into the .h file of SignUpViewController (Assuming you have an IBOutlet property set from Storyboard or Interface Builder
I think a better way of doing this is using a delegate to communicate between ViewControllers. See this answer for a quick example of creating a protocol for the delegate method, setting the second ViewController as the first one's delegate and then calling that method.