这是我的NSURL
let url = NSURL(string: "tel://\(phoneCall)")
尽管 phoneCall
是有效的手机号码字符串,而且我正在真实的 iPhone 上进行测试,但它始终为 nil
。
我试过了
let url = NSURL(string: "tel:\(phoneCall)")
但它仍然nil
。
最佳答案
let phoneCall = "tel://9000002143";
let url:NSURL = NSURL(string:phoneCall);
//OR
var url:NSURL = NSURL(string: "tel://9000002143")
if phoneCall == nil || phoneCall.isEmpty
{
print("phoneCall is empty or nil.")
}
else
{
UIApplication.sharedApplication().openURL(url);
}
关于ios - 电话的 NSURL 始终为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33684255/