谁知道我为什么
致命错误:解开Optional值时意外发现nil
当我使用
let URL = NSURL(string: "https://roads.googleapis.com/v1/snapToRoads?path=-35.27801,149.12958|-35.28032,149.12907")!
该|字符不是有效的URL字符,因此您必须将其替换为百分比转义符。编码整个字符串将自动为您完成
|
var stringUrl = "https://roads.googleapis.com/v1/snapToRoads?path=-35.27801,149.12958|-35.28032,149.12907" let URL = NSURL(string: stringUrl.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!)!