美文网首页
类方法的消息转发

类方法的消息转发

作者: Jean_Lina | 来源:发表于2021-07-08 14:02 被阅读0次
    + (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);
    }
    

    相关文章

      网友评论

          本文标题:类方法的消息转发

          本文链接:https://www.haomeiwen.com/subject/fnftpltx.html