【发布时间】:2017-03-01 20:22:35
【问题描述】:
我一直在努力尝试在地图上发现一个自定义位置...基本的东西(使用 google maps sdk)。
但我在运行时仍然遇到致命错误。
也许我没有正确地将 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>>
}
【问题讨论】:
标签: ios swift swift3 google-maps-sdk-ios