iOS-解决调用performSelector产生警告问题

///不需要带参数情况
if ([self.view respondsToSelector:NSSelectorFromString(@"setSubViews")])
{
// 这样会产生警告
// [self.view performSelector:NSSelectorFromString(@"setSubViews")];
SEL selector = NSSelectorFromString(@"setSubViews");
IMP imp = [self.view methodForSelector:selector];
void (*func)(id, SEL) = (void *)imp;
func(self.view, 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);

你可能感兴趣的:(iOS-解决调用performSelector产生警告问题)