标签:
NSURLSession *session = [NSURLSession sharedSession]; __weak id safeSelf = self; NSURLSessionDataTask *task = [session dataTaskWithRequest:req completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { self.webData = data; if (self.webData) { // 如果获取到了数据 NSXMLParser *paser = [[NSXMLParser alloc]initWithData:self.webData]; paser.delegate = self; [paser parse]; } if ([self.parseResults isEqualToString:@"false"]) { UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"登录失败" message:@"帐号密码错误" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *action = [UIAlertAction actionWithTitle:@"oops" style:UIAlertActionStyleDefault handler:nil]; [alert addAction:action]; //dispatch_async(dispatch_get_main_queue(), ^{ [self presentViewController:alert animated:YES completion:nil]; //}); } }]; [task resume];
[self presentViewController:alert animated:YES completion:nil]语句报错,信息为:
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.
解决方法:
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:alert animated:YES completion:nil];
});
application is modifying the autolayout engine from a background thread解决方案
标签:
原文地址:http://www.cnblogs.com/somebod-Y/p/4866231.html