#pragma mark -- request
-(void)getProductDataWithIsReloadData:(BOOL)isReloadData
{
dispatch_queue_t dispatchQueue = dispatch_queue_create("ted.queue.next", DISPATCH_QUEUE_CONCURRENT);
dispatch_group_t dispatchGroup = dispatch_group_create();
dispatch_group_async(dispatchGroup, dispatchQueue, ^(){
//请求1
[self getNewUserProductData];
NSLog(@"dispatch-1");
});
dispatch_group_async(dispatchGroup, dispatchQueue, ^(){
//请求2
[self getInvestmentDataWithIsReloadData:YES];
NSLog(@"dspatch-2");
});
dispatch_group_notify(dispatchGroup, dispatch_get_main_queue(), ^(){
[self.projectTableView reloadDataWithProductDataAry:self.productDataAry
productNewUserData:self.productNewUserData];
[self.projectTableView.mj_header endRefreshing];
[self.projectTableView.mj_footer endRefreshing];
});
}
-(void)getNewUserProductData
{
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSDictionary *parameters = @{@"isRecommend":@"",
@"status":@"",
@"businessType":@"1",
@"minDeadline":@"0",
@"maxDeadline":@"0",
@"minRate":@"0",
@"maxRate":@"0"};
WEAK_SELF
[NetManager requestWithUrlString:Main_URL method:My_New parameters:parameters finished:^(NetModel *obj) {
// 请求成功
// if ([obj.resultCode isEqualToString:@"SUCCESS"]) {
NSDictionary * dataArrayDic = [obj getResultDictionary];
NSError *err = nil;
weakSelf.productNewUserData = [[JYProductModel alloc] initWithDictionary:dataArrayDic error:&err];
NSLog(@"%@", dataArrayDic);
// }else{
// [self errorPrompt:1.5 promptStr:[obj getResultMessage]];
// }
dispatch_semaphore_signal(sema);
} failed:^(NetModel *obj) {
dispatch_semaphore_signal(sema);
}];
//若计数为0则一直等待
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
}
网友评论