iOS-GCD_dispatch_group_t實現for迴圈非同步任務完成之後再進行下一次迴圈

weixin_33912246發表於2018-09-04
    dispatch_group_t group = dispatch_group_create();
    for (NSInteger i = 0; i<self.dataArr.count; ++i) {
        dispatch_group_enter(group);
           //非同步任務
            [xxxblock:^(NSString *str) {
                dispatch_group_leave(group);
            }];
     }
    dispatch_group_notify(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
    //完成後 要執行的程式碼
   });

相關文章