有没有办法让编译器忽略这个特定的警告?
这就是我所做的:
UIViewController *firstViewController = AppDelegate.instance.viewController;
//open the view of the clicked subItem
if ([firstViewController respondsToSelector:@selector(openView:inView:)]) {
[firstViewController openView:subItem.itemText.text inView:activeScreen]; //warning on this line
}
我知道一种可行的方法是更改UIViewController
为ViewController
(班级名称)。但是这个修复在未来不会起作用,所以我只是在寻找一种方法来忽略这个警告。
它在未来不会起作用,因为,我会做这样的事情:
//.m
UIViewController *firstViewController;
//.h
if (someCondition) {
firstViewController = AppDelegate.instance.viewController;
}
else{
firstViewController = AppDelegate.instance.otherViewController;
}
if ([firstViewController respondsToSelector:@selector(openView:inView:)]) {
[firstViewController openView:subItem.itemText.text inView:activeScreen]; //warning on this line
}