gpt4 book ai didi

ios - UILabel/UITextField 不使用异步 HTTP 请求更新

转载 作者:搜寻专家 更新时间:2023-11-01 06:39:39 25 4
gpt4 key购买 nike

<分区>

当我发出异步 http 请求时,包含文本的 UITextField 不会更新,它只会在我单击它时显示文本(还有 UILabel ), 我试着把它放在 viewDidLoad() 覆盖方法之前,但我什么也没得到

HTTP 请求:

func asincrono(){
print("A buscar: \(completeLink!) \n")
let url:NSURL = NSURL(string: "https://openlibrary.org/api/books?jscmd=data&format=json&bibkeys=ISBN:\(completeLink!)")!
let urlSession:NSURLSession = NSURLSession.sharedSession()
let bloque = { (datos : NSData?, resp: NSURLResponse?,error:NSError?)-> Void in let texto = NSString(data: datos!, encoding: NSUTF8StringEncoding)
if error?.code>=400 && error?.code<500 {
self.jsonText.text = "Error, bad connection"
}else if error?.code == nil{
/*let index1 = (texto! as String).startIndex.advancedBy(2)
let substring1 = (texto! as String).substringToIndex(index1)
print(substring1)*/
self.jsonText.text = texto! as String
print("Datos obtenidos: \n\n\(self.jsonText.text!)")
}
print(texto!)
}
let dt = urlSession.dataTaskWithURL(url, completionHandler: bloque)
dt.resume()
}

viewDidLoad() 方法:

override func viewDidLoad() {
asincrono()
super.viewDidLoad()
jsonText.text = jsonText.text
}

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