let MoovitURL: String = "moovit://nearby?lat=40.758896&lon=-73.985130&title=\(barNameTemplate)&partner_id=<nightout>"
let escapedString = MoovitURL.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
UIApplication.shared.openURL(URL(string: escapedString!)!)
fatal error: unexpectedly found nil while unwrapping an Optional value
2017-08-14 22:49:35.983585+0300 TestApp[10658:6538686] fatal error: unexpectedly found nil while unwrapping an Optional value
UIApplication.shared.openURL(URL(string: MoovitURL)!)
答案 0 :(得分:-1)
Swift并不认为你的字符串是一个实际的URL,所以它返回nil。当您试图强行打开它(!
)时,它会出错。