美文网首页
消息机制

消息机制

作者: 健健锅 | 来源:发表于2019-01-18 10:52 被阅读15次

    JSPATCH
    (https://www.cnblogs.com/graveliang/p/5809519.html)

    ( https://www.cnblogs.com/zhang-chi/p/6179791.html)
    ( https://www.cnblogs.com/fengmin/p/5880443.html)

    ( https://www.jianshu.com/p/7e2efff789e2)
    1.检查是否动态添加 如果动态添加 执行添加的 没有进入下一步

         void play (id self, SEL _cmd)
         {
            NSLog(@"实现被转移到这里");
         }
         + (BOOL)resolveInstanceMethod:(SEL)sel{
             if (sel == @selector(play)){
         
                 class_addMethod([self class], sel,(IMP)play, "v@:");
         
                 return YES;
             }
         
             return [super resolveInstanceMethod:sel];
         
         }
         ```
         二,如果没有动态,就看看有没有指定其他的类实现
    
     - (id)forwardingTargetForSelector:(SEL)aSelector OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0){
     return [[Guitar alloc] init];
     }
    
         三,如果还没有,那么就进行获取签名,如果获取到 NSMethodSignature
         methodSignatureForSelector
         消息:
         最后给他他  如果没有就报错
    
     - (void)forwardInvocation:(NSInvocation *)anInvocation
    

    相关文章

      网友评论

          本文标题:消息机制

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