-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNSOperationQueue+JPHAsync.m
46 lines (38 loc) · 1.39 KB
/
NSOperationQueue+JPHAsync.m
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
45
46
//
// NSOperationQueue+JPHAsync.m
// JPHAsyncOperation
//
// Created by Pierre Houston on 2015-06-19.
// Copyright © 2015 Pierre Houston. All rights reserved.
//
#import "NSOperationQueue+JPHAsync.h"
@implementation NSOperationQueue (JPHAsync)
- (void)addAyncOperationWithBlock:(JPHAsyncOperationBlock)block;
{
JPHAsyncOperation *operation = [[JPHAsyncOperation alloc] initWithBlock:block];
[self addOperation:operation];
}
- (void)addAyncOperationNamed:(NSString *)name withBlock:(JPHAsyncOperationBlock)block
{
JPHAsyncOperation *operation = [[JPHAsyncOperation alloc] initWithBlock:block];
if (name != nil)
operation.name = name;
[self addOperation:operation];
}
- (void)addAyncOperationWithDependancies:(NSArray *)dependencies block:(JPHAsyncOperationBlock)block
{
JPHAsyncOperation *operation = [[JPHAsyncOperation alloc] initWithBlock:block];
for (NSOperation *dependency in dependencies)
[operation addDependency:dependency];
[self addOperation:operation];
}
- (void)addAyncOperationNamed:(NSString *)name withDependancies:(NSArray *)dependencies block:(JPHAsyncOperationBlock)block
{
JPHAsyncOperation *operation = [[JPHAsyncOperation alloc] initWithBlock:block];
if (name != nil)
operation.name = name;
for (NSOperation *dependency in dependencies)
[operation addDependency:dependency];
[self addOperation:operation];
}
@end