我有UITextField名为textField ,用户可以在其中使用NSUserDefaults保存电话号码。然后我让IBAction拨打该号码。如何将用户已保存到UITextField的数字放入该操作?
-(IBAction)callPhone:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:123456"]];
}
更新
- (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];
}