func datakontrol(){
let url = NSURL(string: "http://localhost.192.168.1.40.xip.io:8888/store1.php")
URLSession.shared.dataTask(with: (url as URL?)!, completionHandler: {(data, response, error) -> Void in
if let jsonObj = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? NSDictionary {
guard let telefon = jsonObj!["telefon"] as? String else { return }
GlobalVariables.telefonum = telefon
}
}).resume()
当我尝试跟踪此代码从dataTask跳到代码结束。我想问一个错误的问题。我想要这个代码完成。对不起我的英语不好。如何通过快速异步块
谢谢你的帮助。我添加了打印,现在睡觉了。再次谢谢你。 –
@ÜmitGündüz好,我不知道这里的用例是什么,所以我无法识别你需要“睡眠”的地方,但小建议是,你应该尽量避免在你的代码中尽可能多地使用“sleep”我使用 – 3stud1ant3
数据传输之间的观点可能会睡得很糟,但工作起来。 –