ios使用dispatch_group_async和dispatch_group_notify异步转同步

http://www.dreamingwish.com/article/gcd介绍(二)-多核心的性能.html

 

dispatch_queue_t queue = dispatch_get_global_qeueue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_group_t group = dispatch_group_create();
for(id obj in array)
    dispatch_group_async(group, queue, ^{
        [self doSomethingIntensiveWith:obj];
    });
dispatch_group_notify(group, queue, ^{
    [self doSomethingWith:array];
});
dispatch_release(group);

 

posted on 2015-03-03 15:43  sfce  阅读(552)  评论(0编辑  收藏  举报

导航