iOS Developer

iOS 项目警告处理

2016-11-22  本文已影响856人  景彧

去除警告的方法:

#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 项目警告处理(附表)

上一篇下一篇

猜你喜欢

热点阅读