Skip to content

Instantly share code, notes, and snippets.

@hasanadil
Created August 14, 2015 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasanadil/0541f0d1a06227548a9a to your computer and use it in GitHub Desktop.
Save hasanadil/0541f0d1a06227548a9a to your computer and use it in GitHub Desktop.
//wait on everything to be completed
dispatch_barrier_async(weakMe.concurrentQueue, ^{
//Get the highest count amont the worker results
NSArray* allCounts = [workerResults allValues];
NSSortDescriptor* countSort = [[NSSortDescriptor alloc] initWithKey:@"count" ascending:NO];
NSArray* sortedCounts = [allCounts sortedArrayUsingDescriptors:@[countSort]];
HAColorComponentsCount* colorComponentCount = [sortedCounts firstObject];
HAColorComponents *components = colorComponentCount.components;
NSColor *dominantColor = [NSColor colorWithCalibratedRed:components.red/255.f green:components.green/255.f blue:components.blue/255.f alpha:1.0];
NSTimeInterval time = [[NSDate date] timeIntervalSinceDate:startTime];
if (completion) {
dispatch_async(dispatch_get_main_queue(), ^{
completion(dominantColor, time);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment