为什么说,你纯看代码而没有碰到这个场景你就算看懂了也没法理解?
我碰到了一个什么问题? for (int i = 1; i <= 10; i++) { [Seller requestSellerWithCompletion:^(id object) { NSLog(@"finished download %d",i); }]; } 这个requestSellerWithCompletion方法就是我封装了最简单的一个AFNetworkingOperation请求. 内容如下. + (void)requestSellerWithCompletion:(requestFinishedCompletionBlock)successBlock{ AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager GET:kRequestSellerURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { NSArray *sellerArray = [MTLJSONAdapter modelsOfClass:[Seller class] fromJSONArray:responseObject[@"data"] error:nil]; if (successBlock) { // NSLog(@"current operation count is %d",[manager.operationQueue operations].count); successBlock(sellerArray); } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { }];} 好,我们执行以下.console打出的结果如下. |