Created
May 1, 2012 20:40
-
-
Save jnjosh/2571191 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
// | |
// NSMutableArray+TTAdditions.h | |
// tester | |
// | |
// Created by Joshua Johnson on 5/1/12. | |
// Copyright (c) 2012 Two Toasters, LLC. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSMutableArray (TTAdditions) | |
/** Sort Mutable Array using an NSComparator with a completion handler | |
* | |
* @param comparator an NSComparator block for comparing results | |
* @param handler a completion handler to perform when the sort is complete | |
*/ | |
- (void)tt_sortUsingComparator:(NSComparator)comparator withCompletionHandler:(void (^)(void))handler; | |
@end |
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
// | |
// NSMutableArray+TTAdditions.m | |
// tester | |
// | |
// Created by Joshua Johnson on 5/1/12. | |
// Copyright (c) 2012 Two Toasters, LLC. All rights reserved. | |
// | |
#import "NSMutableArray+TTAdditions.h" | |
static dispatch_queue_t sort_queue = NULL; | |
@implementation NSMutableArray (TTAdditions) | |
- (void)tt_sortUsingComparator:(NSComparator)comparator withCompletionHandler:(void (^)(void))handler | |
{ | |
if (sort_queue == NULL) { | |
sort_queue = dispatch_queue_create("com.twotoasters.additions.sorting", 0); | |
} | |
dispatch_async(sort_queue, ^{ | |
[self sortUsingComparator:comparator]; | |
if (handler) { | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
handler(); | |
}); | |
} | |
}); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment