Xcode Obj - C - recuperar texto inserido pelo usuário do Alert Box IOS8
Eu tenho o seguinte código que permitirá ao usuário inserir seu nome completo em uma caixa de alerta;
//Creates the alert box
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:@"Congratulations"
message:@"You Have The High Score, Enter Your Name"
preferredStyle:UIAlertControllerStyleAlert];
//Adds a text field to the alert box
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField)
{
textField.placeholder = NSLocalizedString(@"Enter Full Name", @"Fullname");
}];
[self presentViewController:alertController animated:YES completion:nil];
//Creates a button with actions to perform when clicked
UIAlertAction *SaveAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"SAVE",@"Save Action")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
//Stores what has been inputted into the NSString Fullname
NSString *Fullname = alertController.textFields.firstObject;
NSLog(@"Name Stored %@",Fullname);
[self performSegueWithIdentifier:@"NoNextSlide" sender:self];
}];
[alertController addAction:SaveAction];
Você notará na linha;
NSLog(@"Name Stored %@",Fullname);
Isso retornará o seguinte;
2015-03-03 11:54:19.374 Master Game[1864:26681] Name Stored <_UIAlertControllerTextField: 0x7f9cf61ed780; frame = (4 4; 229 16); text = 'Shaun'; clipsToBounds = YES; opaque = NO; gestureRecognizers = <NSArray: 0x7f9cf6084bd0>; layer = <CALayer: 0x7f9cf61854b0>>
Como obtenho apenas o 'Shaun' inserido de lá para que eu possa salvá-lo e usá-lo no futuro?