I have UITextField named textField where user can save phone number with NSUserDefaults. Then I have IBAction to call that number. How can I put to that action a number what user have been saved to UITextField?
-(IBAction)callPhone:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:123456"]];
}
UPDATE
- (IBAction) saveBtnPresssed : (id) sender
{
myString1 = [[NSString alloc] initWithFormat:textField.text];
[textField setText:myString1];
NSUserDefaults *stringDefault = [NSUserDefaults standardUserDefaults];
[stringDefault setObject:myString1 forKey:@"stringKey"];
}
- (void)viewDidLoad
{
[textField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey"]];
[super viewDidLoad];
}
The string you are looking for is returned by:
If you saved that to user defaults then you can just:
}
EDIT:
so the resulting string should be “tel:” + the actual number from the text field instead of “tel:123456”