按下登录按钮后出现错误,这与JSON序列化有关。
Xcode中的错误的屏幕截图:
let session = URLSession.shared
let task = session.dataTask(with: request) { data, response, error in
if error != nil {
comletion(nil, error)
return
}
let newData = data!.subdata(in: 5..<data! .count)
let result = try! JSONSerialization.jsonObject(with: newData, options: JSONSerialization.ReadingOptions.allowFragments) as! [String: Any]
comletion(result, nil)
}
task.resume()
}
致命错误:“尝试!”表达式意外引发错误:错误 Domain = NSCocoaErrorDomain代码= 3840“某些情况看起来像是'true' 但不在字符0周围。” UserInfo = {NSDebugDescription = Something 看起来像“ true”,但不在字符0周围。}:file / Users / macpro / Desktop /在地图上/在地图上/UdacityAPI.swift,第30行