2
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);
}];
enqueueBatchOfHTTPRequestOperations完成在操作和operation1塊之前觸發。在調用完所有AFJSONRequestOperation完成之前,AFNetworking enqueRequestOperations觸發完成
沒有閱讀https://github.com/AFNetworking/AFNetworking/issues/362並嘗試使用dispatch_group進行修復,但它仍然無效。