if ([self.dockView respondsToSelector:NSSelectorFromString(@"setSubViews")]) {
// 这样会产生警告
// [self.dockView performSelector:NSSelectorFromString(@"setSubViews")];
SEL selector = NSSelectorFromString(@"setSubViews");
IMP imp = [self.dockView methodForSelector:selector];
void (*func)(id, SEL) = (void *)imp;
func(self.dockView, selector);
}
下面是带参数情况
SEL selector = NSSelectorFromString(@"processRegion:ofView:");
IMP imp = [_controller methodForSelector:selector];
CGRect (*func)(id, SEL, CGRect, UIView *) = (void *)imp;
CGRect result = func(_controller, selector, someRect, someView);
网友评论