美文网首页
实例方法的动态方法解析

实例方法的动态方法解析

作者: Jean_Lina | 来源:发表于2021-07-08 14:00 被阅读0次
- (void)sing;
- (void)singSong {
    NSLog(@"%s", __func__);
}
#pragma mark 实例方法的动态方法解析
+ (BOOL)resolveInstanceMethod:(SEL)sel {
    if (sel == @selector(sing)) {
        Method method = class_getInstanceMethod(self, @selector(singSong));
        class_addMethod(self, sel, method_getImplementation(method), method_getTypeEncoding(method));
        return YES;
    }
    return [super resolveInstanceMethod:sel];
}

相关文章

网友评论

      本文标题:实例方法的动态方法解析

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