AFNetworking是否调用主线程上的完成块?或者它是否在后台调用,需要我手动将UI更新发送到主线程?在主线程上调用AFNetworking成功/失败块吗?
使用代码来代替的话,这是从AFNetworking documentation与调用NSLog
示例代码由UI更新替代:
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
self.label.text = JSON[@"text"];
} failure:nil];
它应该被写成这样?
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
dispatch_async(dispatch_get_main_queue(), ^{
self.label.text = JSON[@"text"];
});
} failure:nil];
@tdarr所有的源代码都可用,看看,你可以知道这一切 – onmyway133