Created
August 14, 2015 18:08
-
-
Save hasanadil/0541f0d1a06227548a9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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