使用#pragma在Xcode中禁止“实例方法未找到”警告 [英] Using #pragma to suppress “Instance method not found” warnings in Xcode
问题描述
我想用 #pragma
(在Xcode中)来压制警告:
我试过了:
#pragma GCC diagnostic ignored-Wmissing-declarations
和其他几个,但没有任何作用。
什么警告会导致未找到实例方法?
编辑
这里要求的是实际的代码:
...
如果(sampleRate> 0&&![self isFinishing])//< ---这里警告
{
return self.progress;
}
...
构建日志输出:
/Users/User1/Documents/Project/branch/client/Folder/CodeFile.m:26:32:{26 :32-26:50}:warning:找不到实例方法'-isFinishing'(返回类型默认为'id')[3]
if(sampleRate> 0&&![self isFinishing])
^ ~~~~~~~~~~~~~~~~~
请参阅: https://stackoverflow.com/a/ 34043306/89035 为#pragma压制找不到实例方法的警告。
虽然看起来真的 #pragma
解决方案不存在可以通过使用 -w
来关闭单个文件中的警告。开关。
注意:此解决方案适用于Xcode 4.2及以上版本
- S选择目标
- 点击Build Phases标签
- 在Compile Sources下添加
-w
code>切换到您想要禁止警告的文件
I want to use #pragma
(in Xcode) to suppress the warning:
warning: instance method '-someMethod' not found (return type defaults to 'id')
I've tried:
#pragma GCC diagnostic ignored "-Wmissing-declarations"
And several others, but nothing works.
What warning causes the "instance method not found"?
Edit
As requested here is the actual code:
...
if (sampleRate > 0 && ![self isFinishing]) //<--- Warning here
{
return self.progress;
}
...
And the build log output:
/Users/User1/Documents/Project/branch/client/Folder/CodeFile.m:26:32:{26:32-26:50}: warning: instance method '-isFinishing' not found (return type defaults to 'id') [3]
if (sampleRate > 0 && ![self isFinishing])
^~~~~~~~~~~~~~~~~~
See: https://stackoverflow.com/a/34043306/89035 for a #pragma to suppress "instance method not found" warnings.
While it seem that a true #pragma
solution to this does not exist turning off the warnings in individual files can be accomplished by use of the -w
switch.
NB: This solution is for Xcode 4.2 and above
- Select the target
- Click on the "Build Phases" tab
- Under "Compile Sources" add the
-w
switch to the file(s) you wish to suppress warnings on
这篇关于使用#pragma在Xcode中禁止“实例方法未找到”警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!