29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
@implementation XMPPCallback
#ifdef OF_HAVE_BLOCKS
+ callbackWithBlock: (xmpp_callback_block_t)block
{
return [[(XMPPCallback*)[self alloc] initWithBlock: block] autorelease];
}
- initWithBlock: (xmpp_callback_block_t)block_
{
self = [super init];
@try {
block = [block_ copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
|
|
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
@implementation XMPPCallback
#ifdef OF_HAVE_BLOCKS
+ callbackWithBlock: (xmpp_callback_block_t)block
{
return [[(XMPPCallback*)[self alloc] initWithBlock: block] autorelease];
}
- initWithBlock: (xmpp_callback_block_t)block
{
self = [super init];
@try {
_block = [block copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
return self;
}
- (void)dealloc
{
[_target release];
#ifdef OF_HAVE_BLOCKS
[block release];
#endif
[super dealloc];
}
- (void)runWithIQ: (XMPPIQ*)iq
connection: (XMPPConnection*)connection
{
#ifdef OF_HAVE_BLOCKS
if (block != NULL)
block(connection, iq);
else
#endif
[_target performSelector: _selector
withObject: connection
withObject: iq];
}
@end
|
|
|
|
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
return self;
}
- (void)dealloc
{
[_target release];
#ifdef OF_HAVE_BLOCKS
[_block release];
#endif
[super dealloc];
}
- (void)runWithIQ: (XMPPIQ*)iq
connection: (XMPPConnection*)connection
{
#ifdef OF_HAVE_BLOCKS
if (_block != NULL)
_block(connection, iq);
else
#endif
[_target performSelector: _selector
withObject: connection
withObject: iq];
}
@end
|