请求同一个接口的数据,我现在是第一个请求成功后请求下一个,有没有其他更快的方法呢?网上说可以自定义几个串行队列,并发执行?求方法。谢谢
接口:
-(void)requestfilterData:(NSString *)item
{
NSString *urlStr = [NSString stringWithFormat:@"%@/api/product/filter/list?filtername=%@" ,SERVER_ADDRESS,item];
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60];
[request setHTTPMethod:@"GET"];
[NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue alloc]init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (connectionError) {
NSLog(@" good commet list recv data error");
}else
{
[self receivedfilterConditionsReturnJSON:data];
}
}];
}
-(void)receivedfilterConditionsReturnJSON:(NSData *)data
{
NSError *localError = nil;
id parsedObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&localError];
if (localError != nil) {
NSLog(@"sport train filter list JSON data error: %@", [localError description]);
return;
}
NSDictionary *recvDic = (NSDictionary *)parsedObject;
//接收商品评论数据
NSString *result = [recvDic objectForKey:@"result"];
if ([result isEqualToString:@"1"]) {
dispatch_async(dispatch_get_main_queue(), ^{
[self showItemController:recvDic];
});
}
}
需求:实在页面出现的时候,要根据参数分三次调用这个接口(服务端就是这么设计的,并不是一次返回了)。