+ (void)eat;
#pragma mark 类方法的消息转发
+ (BOOL)resolveClassMethod:(SEL)sel {
if (sel == @selector(eat)) {
NSLog(@"+ resolveClassMethod");
return YES;
}
return [super resolveClassMethod:sel];
}
+ (id)forwardingTargetForSelector:(SEL)aSelector {
if (aSelector == @selector(eat)) {
NSLog(@"+ forwardingTargetForSelector");
return nil;
}
return [super forwardingTargetForSelector:aSelector];
}
+ (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
if (aSelector == @selector(eat)) {
NSLog(@"+ methodSignatureForSelector");
return [NSMethodSignature signatureWithObjCTypes:"v@:"];
}
return [super methodSignatureForSelector:aSelector];
}
+ (void)forwardInvocation:(NSInvocation *)anInvocation {
NSLog(@"+ forwardInvocation");
NSLog(@"1 %@", anInvocation.target);
NSLog(@"2 %s", anInvocation.selector);
}
网友评论