更换NSURLSession后 报错 This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release. 然后balabala还有一堆栈或堆上的错误。
找了半天,最终结论是,刷新UI要回到主线程。由于是自己写的网络请求类,每个界面刷新UI不可能都加回到主线程。so
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
});
}
在请求下数据来后 就回到主线程。这样就解决啦