【发布时间】:2016-08-01 13:32:05
【问题描述】:
我正在尝试使用 MFMessageComposer 为用户预填充短信。我正在尝试使用存储在可变数组中的变量并使用该号码来预填充电话号码。但是,它不适用于收件人部分的以下代码。我尝试将其更改为字符串,并将其添加到数组中。手机什么都做不了。
但是,如果我使用 @[@"123132131235"] 进行手动编号;对于收件人来说,它会起作用。
- (IBAction)smsSend:(id)sender {
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
[controller setMessageComposeDelegate:self];
if([MFMessageComposeViewController canSendText])
{
controller.recipients = [[NSArray alloc] initWithObjects:[Detail valueForKey:@"Phone"], nil];
NSLog(@"%@",[Detail valueForKey:@"Phone"]);
controller.body = @"Hello testing";
[self presentViewController:controller animated:YES completion:NULL];
} else {
NSLog(@"cannot send");
}
}
}
请帮帮我。
干杯, 托尼。
【问题讨论】:
-
你能不能
NSLog(@"%@",[Detail valueForKey:@"Phone"])看看你得到了什么? -
什么是
[Detail valueForKey:@"Phone"]?它返回什么样的对象? -
当我做 NSLog(@"%@",[Detail valueForKey:@"Phone"]) 我得到了正确的数字,比如 123456789。
-
[Detail valueForKey:@"Phone"],Detail是可变数组,Phone是我从核心数据添加到可变数组的对象。
-
你能登录
controller.recipients吗?我也想知道[[Detail valueForKey:@"Phone"] class]是否真的返回了NSString对象。
标签: ios objective-c sms message