因此基本上http请求只是停止了错误处理。 谁能解释这意味着什么?我什至不能用谷歌搜索,谢谢
2020-05-18 11:40:09.089446+0600 Flat.kz[68019:9710896] Connection 1: received failure notification
2020-05-18 11:40:09.089784+0600 Flat.kz[68019:9710896] Connection 1: failed to connect 3:-9816, reason -1
2020-05-18 11:40:09.089972+0600 Flat.kz[68019:9710896] Connection 1: encountered error(3:-9816)
2020-05-18 11:40:09.096581+0600 Flat.kz[68019:9710896] Task <87D82A7A-795A-4BF2-A827-742172C1115C>.<1> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9816])
我知道网址是正确的,
let semaphore = DispatchSemaphore(value: 0)
let session = URLSession.shared
session.dataTask(with: request, completionHandler: { (data: Data?, response: URLResponse?, error: Error?) in
if let data = data
{
do{
let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
print(json)
let results = try decoder.decode(decode.self, from: data)
result = results
semaphore.signal()
} catch {
print(error)
}
}
}).resume()
semaphore.wait()
if result != nil{
return result
}
else {return nil}