Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dispatch Awesome

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →
Sam Soffes
January 10, 2013

Dispatch Awesome

An overview of a few some awesome libdispatch features.

This talk was given at NSMeetup in San Francisco, California.

Sam Soffes

January 10, 2013

Transcript

28 slides
  1. dispatch_queue_t queue = dispatch_get_main_queue(); dispatch_group_t group = dispatch_group_create(); dispatch_group_async(group, queue,

    ^{ ! NSLog(@"Hello"); }); dispatch_group_async(group, queue, ^{ ! NSLog(@"World"); }); dispatch_group_notify(group, queue, ^{ ! NSLog(@"Done!"); }); dispatch_release(group);
  2. dispatch_semaphore_t s = dispatch_semaphore_create(0); dispatch_semaphore_signal(s); dispatch_async(backgroundQueue, ^{ ! dispatch_semaphore_wait(s, DISPATCH_TIME_FOREVER);

    ! dispatch_async(dispatch_get_main_queue(), ^{ NSLog(@"Animation is done!"); ! }); }); [UIView animateWithDuration:0.3 animations:block completion:^(BOOL finished) { // ... dispatch_semaphore_signal(s); }];

More Decks by Sam Soffes

Other Decks in Programming