0

I'm trying this

SignUpViewController *userEmail=[[SignUpViewController alloc] init];
userEmail.emailAddress.text=email; 

but is not working.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Georgiana
  • 127
  • 3
  • 11
  • 1
    Please provide more info. What's the context? Are you using nibs or storyboards? How are you calling this? Where are you calling this? What is "email"? What is "userEmail"? – Ethan Mick Aug 18 '14 at 19:42

3 Answers3

1

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; 

}
Dipu Rajak
  • 693
  • 5
  • 15
0

Move your emailAddress @property into the .h file of SignUpViewController (Assuming you have an IBOutlet property set from Storyboard or Interface Builder

0

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.

Community
  • 1
  • 1
Mike Cole
  • 1,291
  • 11
  • 19