从后台线程调用,不支持在uiview上从后台线程执行

时间:2018-10-09 05:26:34

标签: objective-c

self.dataTask =[self.urlSession dataTaskWithRequest:self.urlRequest completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error)
    {

    self.dataDict =[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
    //NSLog(@"data in dict is %@",[[[[self.dataDict objectForKey:@"feed"]objectForKey:@"results"]objectAtIndex:1]objectForKey:@"name"]);
     dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    TableViewController *tvc=[self.storyboard instantiateViewControllerWithIdentifier:@"tableVC"];
         tvc.reciverDict=self.dataDict;
    [self presentViewController:tvc animated:YES completion:^{
    }];
});

}];

 [self.dataTask resume];

}

当我实例化tableviewcontroller得到异常时,这就是为什么我从主队列调用它仍然导致异常的原因。

0 个答案:

没有答案