O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dispatch Groups

Sometimes you want to fan some work out to a number of different queues and then wait until everything completes. For instance, rendering a page in a server might involve hitting a database, running the text through a rendering engine, and appending any insightful and relevant comments that have been left on the page.

A dispatch group is a collection of blocks that have been dispatched onto queues asynchronously. To create a group to track the collection of blocks, you use

dispatch_group_t dispatch_group_create (void);

Rather than dispatching directly onto other queues, you would use dispatch_group_async() to put the block onto a queue, but you also add the work item to the work group.

void dispatch_group_async (dispatch_group_t ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required