首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AFNetworking enqueRequestOperations在调用所有AFJSONRequestOperation完成之前触发完成

AFNetworking enqueRequestOperations在调用所有AFJSONRequestOperation完成之前触发完成
EN

Stack Overflow用户
提问于 2013-04-18 22:42:39
回答 1查看 260关注 0票数 2
代码语言:javascript
复制
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://twitter.com"]];

NSURL *url = [NSURL URLWithString:@"https://alpha-api.app.net/stream/0/posts/stream/global"];
NSURLRequest *r = [NSURLRequest requestWithURL:url];

AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:r success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    NSLog(@"App.net Global Stream: %@", JSON);
} failure:nil];
AFJSONRequestOperation *operation1 = [AFJSONRequestOperation JSONRequestOperationWithRequest:r success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    NSLog(@"App.net Global Stream: %@", JSON);
} failure:nil];

[client enqueueBatchOfHTTPRequestOperations:@[operation, operation1] progressBlock:^(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations) {

} completionBlock:^(NSArray *operations) {
    NSLog(@"%@", operations);
}];

在操作和operation1阻塞之前触发enqueueBatchOfHTTPRequestOperations完成。

我读了https://github.com/AFNetworking/AFNetworking/issues/362,并尝试了用dispatch_group修复,但仍然不起作用。

EN

回答 1

Stack Overflow用户

发布于 2013-07-25 06:12:08

将您的代码更改为使用AFHTTPRequestOperation而不是AFJSONRequestOperation,并使用NSJSONSerialization手动解析JSON,您将发现队列完成块在所有操作按需完成后触发。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16086051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档