How to get rid of the 'undeclared selector' warning

前端 未结 12 2169
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 10:53

I want to use a selector on an NSObject instance without the need for an implemented protocol. For example, there\'s a category method that should set an error prop

12条回答
  •  暖寄归人
    2020-12-12 11:32

    Another option would be to disable the warning with:

    #pragma GCC diagnostic ignored "-Wundeclared-selector"
    

    You can place this line in the .m file where the warning occurs.

    Update:

    It works also with LLVM like this:

    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wundeclared-selector"
    
    ... your code here ...
    
    #pragma clang diagnostic pop
    

提交回复
热议问题