- (int)sheep:(int)time;
#pragma mark 实例方法的消息转发
+ (BOOL)resolveInstanceMethod:(SEL)sel {
if (sel == @selector(sheep:)) {
NSLog(@"+ resolveInstanceMethod");
return YES;
}
return [super resolveInstanceMethod:sel];
}
- (id)forwardingTargetForSelector:(SEL)aSelector {
if (aSelector == @selector(sheep:)) {
NSLog(@"- forwardingTargetForSelector");
return nil;
}
return [super forwardingTargetForSelector:aSelector];
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
if (aSelector == @selector(sheep:)) {
NSLog(@"- methodSignatureForSelector");
return [NSMethodSignature signatureWithObjCTypes:"i@:i"];
}
return [super methodSignatureForSelector:aSelector];
}
- (void)forwardInvocation:(NSInvocation *)anInvocation {
if (anInvocation.selector == @selector(sheep:)) {
NSLog(@"- forwardInvocation");
int retValue;
[anInvocation getReturnValue:&retValue];
int time;
[anInvocation getArgument:&time atIndex:2];
NSLog(@"retValue %d", retValue);
NSLog(@"time %d", time);
}
}
网友评论