PerformSelector warning

前提是你 提交于 2019-11-28 07:44:04

This is a warning generated by the compiler because -Wundeclared-selector was used while compiling and automatic reference counting (ARC) is enabled. This can be, in general, safely ignored, as it's obvious that the selector in the variable named "selector" is unknown at compile time, as it will have its value assigned at runtime.

Your if ... respondsToSelector: selector won't work because your selector is just the name of the method. For your case you need to check

if ([delegate respondsToSelector: @selector(method::)]

and for the other case just for method:.

Anyway, you can supress the warning like this:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
    [self performSelector:nextView];
#pragma clang diagnostic pop
EricS

You can also use objc_msgSend instead of performSelector, as described here.

Alex Cio

You could add -Wno-arc-performSelector-leaks for WARNING_CFLAGS in the Build Settings.

Found the solution here

Easiest way is adding this macro to your pch File. Or .m file..

#pragma GCC diagnostic ignored "-Wundeclared-selector"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!