美文网首页
通过字符串调起方法

通过字符串调起方法

作者: liboxiang | 来源:发表于2018-09-06 10:16 被阅读15次
SEL actionSEL = NSSelectorFromString(methodStr);
        if ([self respondsToSelector:actionSEL]) {
            IMP actionIMP = [self methodForSelector:actionSEL];
            void (*func)(id, SEL) = (void *)actionIMP;
            func(self, actionSEL);
        }

相关文章

网友评论

      本文标题:通过字符串调起方法

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