-
Notifications
You must be signed in to change notification settings - Fork 1
/
InvocationRecorder.m
63 lines (48 loc) · 1.2 KB
/
InvocationRecorder.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// InvocationRecorder.m
// Notation
//
// Created by Zachary Schneirov on 12/18/09.
//
#import "InvocationRecorder.h"
@implementation InvocationRecorder
+ (id)invocationRecorder {
return [[[self alloc] init] autorelease];
}
- (void)dealloc {
[target release];
[invocation release];
[super dealloc];
}
- (id)target {
return target;
}
- (NSInvocation *)invocation {
return invocation;
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSEL {
//check the superclass first
NSMethodSignature *theMethodSignature = [super methodSignatureForSelector:aSEL];
return theMethodSignature ? theMethodSignature : [target methodSignatureForSelector:aSEL];
}
- (void)forwardInvocation:(NSInvocation *)anInvocation {
if (invocation != anInvocation) {
[invocation autorelease];
invocation = [anInvocation retain];
[anInvocation setTarget:target];
[invocation retainArguments];
}
}
- (id)prepareWithInvocationTarget:(id)aTarget {
if (target != aTarget) {
[target autorelease];
target = [aTarget retain];
}
return self;
}
@end
@implementation NSInvocation (DescriptionCategory)
- (NSString*)description {
return [NSString stringWithFormat:@"%@: %s", [self target], [self selector]];
}
@end