-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNSThread+BPFoundationExtensions.m
More file actions
44 lines (33 loc) · 1.17 KB
/
NSThread+BPFoundationExtensions.m
File metadata and controls
44 lines (33 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// NSThread+BPFoundationExtensions.m
// BPFoundation
//
// Created by Jon Olson on 7/25/09.
// Copyright 2009 Ballistic Pigeon, LLC. All rights reserved.
//
#import "NSThread+BPFoundationExtensions.h"
@implementation NSThread (BPFoundationExtensions)
#if NS_BLOCKS_AVAILABLE
+ (void)_performBlock:(void (^)())block {
block();
}
+ (void)performOnMainThread:(void (^)())block {
[self performSelectorOnMainThread:@selector(_performBlock:) withObject:[block copy] waitUntilDone:NO];
}
+ (void)performOnMainThread:(void (^)())block waitUntilDone:(BOOL)wait {
[self performSelectorOnMainThread:@selector(_performBlock:) withObject:[block copy] waitUntilDone:wait];
}
+ (void)performInBackground:(void (^)())block {
[self performSelectorInBackground:@selector(_performBlock:) withObject:[block copy]];
}
- (void)_performBlock:(void (^)())block {
block();
}
- (void)perform:(void (^)())block {
[self performSelector:@selector(_performBlock:) onThread:self withObject:[block copy] waitUntilDone:NO];
}
- (void)perform:(void (^)())block waitUntilDone:(BOOL)wait {
[self performSelector:@selector(_performBlock:) onThread:self withObject:[block copy] waitUntilDone:wait];
}
#endif
@end