I made an outlet for a textfield in storyboard. The text field is in a TableViewCell, so I set this up in UsernameTableViewCell:
@property (strong, nonatomic) IBOutlet UITextField *username;
Then, in the SignUpTableViewController, I set am trying to retrieve the value of the TextField that the user enters here:
UsernameTableViewCell *usernameObject = [[UsernameTableViewCell alloc]init];
Now, when I try to get the value of the textfield, I get (null):
NSLog(@"%@", usernameObject.username.text);
How can I fix this so that usernameObject.username.text displays the value that the user entered?
Update:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 2) {
UsernameTableViewCell *usernameObject = [[UsernameTableViewCell alloc]init];
PasswordTableViewCell *passwordObject = [[PasswordTableViewCell alloc]init];
NSLog(@"%@", usernameObject.username.text);
PFUser *user = [PFUser user];
user.username = usernameObject.username.text;
user.password = passwordObject.password.text;
user.email = @"email@example.com";
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
// Hooray! Let them use the app now.
} else {
NSString *errorString = [error userInfo][@"error"];
// Show the errorString somewhere and let the user try again.
}
}];
}
}