I am using Factual to get phone numbers of local restaurants and am giving the end user the option to call that place within my application but it keeps crashing for some strange reason.
This is the code that works:
func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
if item.tag == 1 {
print("\(RestaurantCountry)")
}
}
RestaurantCountry represents the telephone number. It prints the phone number in the console but when I used this code it crashes. Does anybody know why that would happen?
func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
if item.tag == 1 {
let url:NSURL = NSURL(string: "tel://\(RestaurantCountry)")!
UIApplication.sharedApplication().openURL(url)
}
}
This code crashes but I feel like it should work. Can anybody tell me why this would be happening?
I remove the ! and this is what I get. It will not let me use ?