Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 64 lines (44 sloc) 0.974 kb
4f0c627 Allen Ding First release.
authored
1 //
2 // Licensed under the terms in License.txt
3 //
4 // Copyright 2010 Allen Ding. All rights reserved.
5 //
6
7 #import "KWBlock.h"
8
9 @interface KWBlock()
10
11 #pragma mark -
12 #pragma mark Properties
13
14 @property (nonatomic, readonly, assign) KWVoidBlock block;
15
16 @end
17
18 @implementation KWBlock
19
20 #pragma mark -
21 #pragma mark Initializing
22
23 - (id)initWithBlock:(KWVoidBlock)aBlock {
24 if ((self = [super init])) {
25 block = Block_copy(aBlock);
26 }
b940a6e Matt Di Pasquale Convert \t to 4 spaces. Rm trailing whitespace.
mattdipasquale authored
27
4f0c627 Allen Ding First release.
authored
28 return self;
29 }
30
31 + (id)blockWithBlock:(KWVoidBlock)aBlock {
32 return [[[self alloc] initWithBlock:aBlock] autorelease];
33 }
34
35 - (void)dealloc {
36 Block_release(block);
37 [super dealloc];
38 }
39
40 #pragma mark -
41 #pragma mark Properties
42
43 @synthesize block;
44
45 #pragma mark -
46 #pragma mark Calling Blocks
47
48 - (void)call {
49 block();
50 }
51
52 @end
53
54 #pragma mark -
55 #pragma mark Creating Blocks
56
57 KWBlock *theBlock(KWVoidBlock aBlock) {
58 return lambda(aBlock);
59 }
60
61 KWBlock *lambda(KWVoidBlock aBlock) {
62 return [KWBlock blockWithBlock:aBlock];
63 }
Something went wrong with that request. Please try again.