gpt4 book ai didi

IOS Simple rest API 适用于模拟器,但不适用于任何设备

转载 作者:行者123 更新时间:2023-11-28 11:47:32 25 4
gpt4 key购买 nike

此代码在模拟器 iphone 8 Plus 上按预期运行,但在运行到 iphone 8 plus 或 iphone 6 时失败并显示此控制台日志并出现此奇怪的结果。运行当前操作系统版本的 Mac 和两部 iPhone。

import UIKit

let DomainURL = "http://museum-dev.williams.edu:3003/id?labID="

class artObject : Codable {
var ObjectID : Int?
var ObjectName : String?
var Creators : String?
var Medium : String?
var Titles : String?
var LabelUUID : String?

static func fetch(withID id : String){
let urlString = DomainURL + "\(id)"
print("urlString is \(urlString)")

if let url = URL(string: urlString) {
let task = URLSession.shared.dataTask(with: url, completionHandler: { (data,response,error) in
print(String(data: data!,encoding: .ascii) ?? "no data")

if let newArtObj = try? JSONDecoder().decode(artObject.self, from: data!) {
print(newArtObj.Medium ?? "no url")
}


})
task.resume()
}
}
}

class ViewController: UIViewController {


override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
artObject.fetch(withID: "E8EE71C6F5822")
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}


}

urlString 是 http://museum-dev.williams.edu:3003/id?labID=E8EE71C6F5822

2018-09-14 09:47:45.384385-0400 RestFul[330:16235] [] tcp_timers tcp[1] retransmit SYN 3
2018-09-14 09:47:46.389844-0400 RestFul[330:16235] [] tcp_timers tcp[1] retransmit SYN 4
2018-09-14 09:47:47.395361-0400 RestFul[330:16236] [] tcp_timers tcp[1] retransmit SYN 5
2018-09-14 09:47:49.398078-0400 RestFul[330:16234] [] tcp_timers tcp[1] retransmit SYN 6
2018-09-14 09:47:53.403567-0400 RestFul[330:16236] [] tcp_timers tcp[1] retransmit SYN 7
2018-09-14 09:48:00.098736-0400 RestFul[330:16150] Status bar could not find cached time string image. Rendering in-process.
2018-09-14 09:48:01.409005-0400 RestFul[330:16234] [] tcp_timers tcp[1] retransmit SYN 8
2018-09-14 09:48:17.412384-0400 RestFul[330:16236] [] tcp_timers tcp[1] retransmit SYN 9
2018-09-14 09:49:00.722310-0400 RestFul[330:16520] TIC TCP Conn Failed [1:0x1d4168700]: 1:50 Err(50)
2018-09-14 09:49:00.722701-0400 RestFul[330:16236] Task <5D9E2547-23CE-4959-8CF5-211114B1C533>.<1> finished with error - code: -1001
2018-09-14 09:49:00.724537-0400 RestFul[330:16520] Task <5D9E2547-23CE-4959-8CF5-211114B1C533>.<1> HTTP load failed (error code: -1009 [1:50])

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com