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)
( //www.greatytc.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