dispatch_group_async的实际应用

在开发中,遇到N个网络请求都完成后更新UI的需求,这时使用dispatch_group_async就比较简单,具体使用为:

dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);

dispatch_group_t group =dispatch_group_create();

dispatch_group_async(group, queue, ^{

NSLog(@"request1");

});

dispatch_group_async(group, queue, ^{

NSLog(@"request1");

});

dispatch_group_notify(group,dispatch_get_main_queue(),^{

NSLog("updateUI");

})

你可能感兴趣的:(dispatch_group_async的实际应用)