使用#pragma在Xcode中禁止“实例方法未找到”警告 [英] Using #pragma to suppress “Instance method not found” warnings in Xcode

查看:227
本文介绍了使用#pragma在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及以上版本


  1. S选择目标

  2. 点击Build Phases标签

  3. 在Compile Sources下添加 -w
  4. 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

  1. Select the target
  2. Click on the "Build Phases" tab
  3. Under "Compile Sources" add the -w switch to the file(s) you wish to suppress warnings on

这篇关于使用#pragma在Xcode中禁止“实例方法未找到”警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆