从主线程访问引擎后,此应用程序正在从后台线程修改自动布局引擎

时间:2019-06-25 09:25:29

标签: http swift4.2 xcode10.2

我想发出http get请求。在请求后,如果请求可以给出成功的响应,则其他功能运行良好。但是如果无法给出成功的响应,则需要花费很长时间才能加载并出现此问题。完成加载后,打开新活动,然后新活动按钮不起作用。

func httpRequester(url: String){
        let myUrl = NSURL(string: url)
        let request = NSMutableURLRequest(url: myUrl! as URL)
        request.httpMethod = "GET"
        var responseString = "Not Found"
        let task = URLSession.shared.dataTask(with: request as URLRequest) {
            data, response, error in

            if error != nil {
                self.performSegue(withIdentifier: "statusActivity", sender: Any?.self)
                self.removeSpinner()
            }else {
                responseString = String(data: data!, encoding: String.Encoding(rawValue: String.Encoding.utf8.rawValue))!
                print("responseString1 = \(responseString)")
                if responseString == "Not Found" {
                    self.performSegue(withIdentifier: "statusActivity", sender: Any?.self)
                }
                self.removeSpinner()
            }

        }
        task.resume()
    }

救救我。

0 个答案:

没有答案