我一直在努力嘗試和發現一個地圖上的自定義位置...基本的東西(谷歌地圖sdk)。如何在Swift 3中找到自定義位置?
但我仍然在運行時遇到致命錯誤。
也許我沒有正確地從JSON格式轉換爲字典對象?
geocodeURLString = geocodeURLString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlHostAllowed)!
dictionary = try JSONSerialization.jsonObject(with: geocodingResultsData! as Data, options: JSONSerialization.ReadingOptions.mutableContainers) as! Dictionary<NSObject, AnyObject>
//ERROR HERE: fatal error: unexpectedly found nil while unwrapping an Optional value
// Get the response status.
let status = dictionary["status" as NSObject] as! String
if status == "OK" {
let allResults = dictionary["results" as NSObject] as! Array<Dictionary<NSObject, AnyObject>>
}
我不認爲你需要一個API密鑰的地址請求,只爲方向。但你是對的,問題是我的編碼是奇怪的,我的地址網址無效 –