通过字符串调起方法
2018-09-06 本文已影响15人
liboxiang
SEL actionSEL = NSSelectorFromString(methodStr);
if ([self respondsToSelector:actionSEL]) {
IMP actionIMP = [self methodForSelector:actionSEL];
void (*func)(id, SEL) = (void *)actionIMP;
func(self, actionSEL);
}