//信号量
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
//创建全局并行
dispatch_group_t group = dispatch_group_create();
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_group_async(group, queue, ^{
[[ApplicationUtil sharedApplicationUtil] checkVersionIsTheLatest:^(BOOL needUpdate, NSInteger updateType, NSString *updateContent) {
dispatch_semaphore_signal(semaphore);}];
});
dispatch_group_async(group, queue, ^{
[self.request getDiscountCouponWithDict:nil success:^(NSDictionary *dictResult) {
dispatch_semaphore_signal(semaphore);
} failed:^(NSInteger code, NSString *errorMsg) {
dispatch_semaphore_signal(semaphore);
}];
});
dispatch_group_async(group, queue, ^{
[self.request getHomeAdsWithDict:nil success:^(NSDictionary *dictResult) {
dispatch_semaphore_signal(semaphore);
} failed:^(NSInteger code, NSString *errorMsg) {
dispatch_semaphore_signal(semaphore);
}];
});
注:dispatch_semaphore_wait和dispatch_semaphore_signal必须成对出现
网友评论