//信號(hào)量
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
//創(chuàng)建全局并行
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必須成對(duì)出現(xiàn)