美文网首页iOS Developer
iOS 项目警告处理

iOS 项目警告处理

作者: 景彧 | 来源:发表于2016-11-22 14:11 被阅读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 项目警告处理(附表)

相关文章

  • iOS 项目警告处理

    去除警告的方法: 上述的代码块中,正常的代码是没有下方这些代码的。但是呢,这个方法我是已经写了,但是在项目中没有运...

  • 收藏文章

    ios 处理内存警告

  • iOS 项目警告处理(附表)

    1. Semantic Warnings(语义警告) 2. Parser Warnings(解析器警告)

  • iOS 编译过程的原理和应用

    前言 __attribute__ Clang警告处理 预处理 插入编译期脚本 提高项目编译速度 iOS编译 编译器...

  • iOS项目中的警告处理

    一.pod中的警告 pod 'SwifterSwift', '4.2.0',:inhibit_warnings =...

  • iOS - 警告处理

    一、 在Xcode8下兼容iOS10,我们会在控制台遇到下面这个警告错误: 解决方法: 进入Product -> ...

  • iOS preferredStatusBarStyle 不调用

    最近在处理项目中警告⚠️问题因为项目中导航栏颜色有很多种从而状态栏就会产生二种在 iOS 2.0 --> 9.0 ...

  • ios 开发中常见警告处理

    ios 开发中常见警告处理例如: pragma clang diagnostic pushpragma clang...

  • iOS 处理Cocoapods警告

    使用cocoapod引入的第三方,如果第三方库中有警告,可以在podfile文件中增加一句inhibit_all_...

  • iOS内存警告处理

    只要出现内存警告的时候,会第一时间执行 AppDelegate 的 - (void)applicationDidR...

网友评论

    本文标题:iOS 项目警告处理

    本文链接:https://www.haomeiwen.com/subject/aaippttx.html