How do I use "takeStringValueFrom" with Button's onclick event?

I have a button that is properly connected so that clicking on it hits the IBAction "login".

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

      

Now I have connected the button to the username / password text fields using "takeStringValueFrom" but I don't understand how to get these values ​​afterwards?

Hope this makes sense.

EDIT: so basically when I click the Login button this event is fired. I would like to grab values ​​from two text boxes in the same window, what is the best way to do this? I suppose I can use IBOutlet for each of the textboxes ... is this the correct way?

Having re-read the document , it is possible that "takeStringValueFrom" not as I thought.

+1


source to share


1 answer


You want to declare the username and password text fields as IBOutlet

s and then wire them up in Interface Builder. Then, in your handler, login

you use a message stringValue

to retrieve your values:



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

    // check username & password
}

      

+6


source







All Articles