iOS 项目警告处理

去除警告的方法:

#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wunused-function"
local void free_linkedlist(ll)
linkedlist_data* ll;
{
    free_datablock(ll->first_block);
    ll->first_block = ll->last_block = NULL;
}
#pragma clang diagnostic pop

上述的代码块中,正常的代码是没有下方这些代码的。但是呢,这个方法我是已经写了,但是在项目中没有运用到,所以会报出这样的错误,如图错误信息图所示:

代码块:

#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wunused-function"

// edit code

#pragma clang diagnostic pop

错误信息图:


错误信息图.png

在Xcode中选中警告的消息,右击选择Reveal in Log,然后右边会有报告的消息

-Wunused-function

所以上面去除警告是使用

-Wunused-function

这个来写的。其他的警告同理做法就能去除。

Snip20161122_3.png

示例:
我们知道,UIAlertView虽然简单易用,但是呢Apple在iOS 9.0的时候丢弃这个类了,我们在其头文件中可以看到

NS_CLASS_DEPRECATED_IOS(2_0, 9_0, "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead") __TVOS_PROHIBITED

所以平时用到这个方法的时候,项目中Xcode就会给这个地方给出警告。但是也有办法处理这样的警告,如下图所示:


QQ20161126-1@2x.png

<p>
下方罗列出来是一些iOS中常见的一些警告消息,在使用第三方库或者Apple官方过时的方法的时候,都会报警告。

Warning Message
-WCFString-literal input conversion stopped due to an input byte that does not belong to the input codeset UTF-8
-WNSObject-attribute __attribute ((NSObject)) may be put on a typedef only, attribute is ignored
-Wabstract-vbase-init initializer for virtual base class %0 of abstract class %1 will never be used
-Waddress-of-array-temporary pointer is initialized by a temporary array, which will be destroyed at the end of the full-expression
-Warc-maybe-repeated-use-of-weak "weak %select{variable property implicit property instance variable}0 %1 may be accessed multiple times in this %select{function method block lambda}2 and may be unpredictably set to nil assign to a strong variable to keep the object alive
-Warc-non-pod-memaccess %select{destination for source of}0 this %1 call is a pointer to ownership-qualified type %2
-Warc-performSelector-leaks performSelector may cause a leak because its selector is unknown
-Warc-repeated-use-of-weak "weak %select{variable property implicit property instance variable}0 %1 is accessed multiple times in this %select{function method block lambda}2 but may be unpredictably set to nil assign to a strong variable to keep the object alive

关于附件更多信息至链接iOS 项目警告处理(附表)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 15,531评论 4 61
  • 作为一位想赚钱的投资人,从行业的角度看待各种公司是一件十分省力的事情,中国目前存在各行各业,那如何挑选行业,如何赚...
    f7fc6667df11阅读 1,745评论 1 6
  • 我想知道那些只会''读书'',几乎无任何特长的人在大学期间会怎么样。噢,我指的是那些从小到大被安排着上学,...
    晶晶晶胡阅读 365评论 2 6

友情链接更多精彩内容