Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (26 sloc) 716 Bytes
#import "NSThread+mxcl.h"
@implementation NSThread (BlocksAdditions)
- (void)performBlock:(void (^)())block
{
if ([[NSThread currentThread] isEqual:self])
block();
else
[self performBlock:block waitUntilDone:NO];
}
- (void)performBlock:(void (^)())block waitUntilDone:(BOOL)wait
{
[NSThread performSelector:@selector(ng_runBlock:)
onThread:self
withObject:[[block copy] autorelease]
waitUntilDone:wait];
}
+ (void)ng_runBlock:(void (^)())block
{
block();
}
+ (void)performBlockInBackground:(void (^)())block
{
[NSThread performSelectorInBackground:@selector(ng_runBlock:)
withObject:[[block copy] autorelease]];
}
@end
Something went wrong with that request. Please try again.