views:

302

answers:

1

I have a button that correctly wired such that when it is clicked, the "login" IBAction is hit.

- (IBAction) login: (id)sender
{
    NSLog(@"OK");
}

Now, I wired the button to the username/password text fields using "takeStringValueFrom" but I don't understand how to then get at those values?

Hope that makes sense.

EDIT: so basically, when i click the "login" button the above event fires. I'd like to grab the values from two text boxes on that same window, what is the best way to accomplish this? I suppose I could use IBOutlet for each of the text boxes ... is this the correct way?

Re-reading http://tinyurl.com/7pfeul it's possible "takeStringValueFrom" isn't what i thought it was.

+4  A: 

You want to declare your username and password textfields as IBOutlets, and then hook them up in Interface Builder. Then, in your login handler, you use the stringValue message to extract their values:

- (IBAction) login: (id)sender
{
    NSString *username = [usernameTextField stringValue];
    NSString *password = [passwordTextField stringValue];

    // check username & password
}
Adam Rosenfield
thank you much adam.
Keith Fitzgerald