How can I get text from a text field and display it in an alert?
Hello! I am BRAND NEW to Objective-C and Xcode and iOS, so PLEASE be forgiving of what is going to be a stupid question. I have a text field. I want to enter some text, click "return", and see my text in an alert. It doesn't serve any useful purpose, but this is how I learn. So far, I am unsuccessful. Here's my function from my HelloEarthViewController.m file:
-(IBAction)showInputMessageUITextField *)textField
{
if ([textField.text isEqualToString:@""])
{
return;
}
UIAlertView *helloEarthInputAlert = [[UIAlertView alloc]
initWithTitle:@"Name!" message:[NSString stringWithFormat:@"Message: %@", textField.text]
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
// Display this message.
[helloEarthInputAlert show];
}
Then I go option+click the text field and drag it to File's Owner and connect it to "showInputMessage:" Then I run it and the build succeeds, but nothing happens when I click my "return" button on the iPhone simulator.
What have I missed? Where have I gone wrong?
MacBook Pro, OS X Mountain Lion (10.8.3)