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
e5ad3e0 @joecannatti Inital
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 }
2ba89e3 @ultrasaurus upgraded Kiwi to new version that supports breakpoints, commit 93088050d...
ultrasaurus authored
27
e5ad3e0 @joecannatti Inital
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.