【发布时间】:2017-10-22 21:19:31
【问题描述】:
我正在尝试使用 JSON 解析来自 API 的数据并收到以下错误:
Failed to obtain sandbox extension for path=/var/folders/4g/g8pv7pms3_n7grf2y7db_dx00000gn/T/com.apple.dt.Xcode.pg/containers/com.apple.dt.playground.stub.iOS_Simulator.testJSON-CB872E50-7C0F-4640-9B40-BA0EFE9BFA44/Library/Caches/com.apple.dt.playground.stub.iOS_Simulator.testJSON-CB872E50-7C0F-4640-9B40-BA0EFE9BFA44.
我的代码如下:
let url = URL(string: "http://engine.hotellook.com/api/v2/static/hotels.json?locationId=895&token=6251c90d5bc52c88b60a38bd84373513")
let task = URLSession.shared.dataTask(with: url!) { (data, response, error) in
print("IN?")
if error != nil {
print ("ERROR")
}
else {
print("Check2")
if data != nil {
do {
//Array
let myJson = try? JSONSerialization.jsonObject(with: data!, options: [])
if let dictionary = myJson as? [String: Any] {
print(dictionary.description)
}
}
}
}
}
task.resume()
【问题讨论】:
-
@LeoDabus 是的,我是
-
一切正常!谢谢!!!
-
好的,我会的。谢谢!如果需要,您可以添加上述信息作为答案,我会投票并批准它。
标签: json swift xcode api swift-playground