AFNetworking waitUntilFinished是否会阻塞UI线程?谢谢
+ (NSData *)postData:(NSDictionary *)dict url:(NSString *)url { NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:0 error:nil]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; [request setHTTPMethod:@"POST"]; [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)data.length] forHTTPHeaderField:@"Content-Length"]; [request setHTTPBody:data]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { } failure:^(AFHTTPRequestOperation *operation, NSError *error) { }]; [operation start]; [operation waitUntilFinished]; return [operation responseData];//这里会不会阻塞UI线程,在执行failure块的时候,会不会发生闪退? }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不会,AFNetworking是运行在非主线程中的
http://stackoverflow.com/a/16918374/1324208