iOS工程的警告修复

栏目: C · 发布时间: 8年前

内容简介:iOS工程的警告修复

在项目中碰到300+的警告,强迫症只能修复了

1:#warning这个后面添加中文的话,在xcode的左边警告列表页会显示不全,所以推荐使用英文注释

iOS工程的警告修复

2: (Method possibly missing a [super awakeFromNib] call) 这个处理,1:手动添加2:假如这个方法里面没有代码也可以删除这个方法

iOS工程的警告修复

3: (Conflicting return type in implementation of 'supportedInterfaceOrientations': 'UIInterfaceOrientationMask' (aka 'enum UIInterfaceOrientationMask') vs 'NSUInteger' (aka 'unsigned long')) 这个是重写系统的方法时把枚举类型的返回值写成了NSUInteger,返回值类型改回枚举就好。

4: (“View Controller“ is unreachable because it has no entry points, and no identifier for runtime access via -[UIStoryboard instantiateViewControllerWithIdentifier:].) 这个警告是在一个xib中有多个storyboard其中有Storyboard ID为空的storyboard,找到删除。

5: (Automatic Preferred Max Layout Width before iOS 8.0) 这个警告是因为xib中的label控件Preferred Width属性没有设置,勾选Explicit填上0就好。

iOS工程的警告修复

6: (Frame for "Statuslabel" will be different at run time.) 这个在xcode左边警告列表点击这个警告,会自动跳转到对应的xib,点击图上的按钮,然后Update Frames就好

iOS工程的警告修复

7: (Prototype collection view cells must have reuse identifiers) 这个是因为storyboard中拖入了collectionView,自带的collectionViewCell的reuse identifier为空,填入对应的reuse identifier就行

8: (warning: Attribute Unavailable: First baseline layout attribute before iOS 8.0) 点击对应的警告跳转到xib界面在左边的filter中输入first,搜索出来的约束的firstItem和secondItem的constraint把两个都改为center.Y就好了

9:在podfile文件中 增加"inhibit_all_warnings!"这样pod的工程不会显示任何警告。

10:(PerformSelector may cause a leak because its selector is unknown)

iOS工程的警告修复

加入这个宏:#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

11:('dismissModalViewControllerAnimated:' is deprecated: first deprecated in iOS 6.0)

iOS工程的警告修复

加入这个宏:#pragma clang diagnostic ignored"-Wdeprecated"

12: ( Comparison of constant 'NSStreamEventErrorOccurred' (8) with expression of type 'NSStreamStatus' (aka 'enum NSStreamStatus') is always false)

加入这个宏:#pragma clang diagnostic ignored"-Wtautological-compare"

13: ( Null passed to a callee that requires a non-null argument)

iOS工程的警告修复

加入这个宏:#pragma clang diagnostic ignored"-Wnonnull"

14:(Undeclared selector 'DWJQkeyboardWillShow:')

iOS工程的警告修复

加入这个宏:#pragma clang diagnostic ignored"-Wundeclared-selector"

15:(Logical not is only applied to the left hand side of this comparison)

加入这个宏:#pragma clang diagnostic ignored"-Wlogical-not-parentheses"

16:(Auto property synthesis will not synthesize property 'superColor'; it will be implemented by its superclass, use @dynamic to acknowledge intention)

iOS工程的警告修复

加入这个宏:#pragma clang diagnostic ignored"-Wobjc-property-synthesis"

17:('sizeWithFont:forWidth:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:)

iOS工程的警告修复

加入这个宏:#pragma clang diagnostic ignored "-Wdeprecated-declarations"

18:(Unsequenced modification and access to 't')

加入这个宏:#pragma clang diagnostic ignored "-Wunsequenced"

19:(Implicit conversion loses integer precision: 'long' to 'int')

加入这个宏:#pragma clang diagnostic ignored"-Wshorten-64-to-32"

20:(Add explicit braces to avoid dangling else)

加入这个宏:#pragma clang diagnostic ignored"-Wdangling-else"

21:(Unused function 'free_linkedlist')

iOS工程的警告修复

加入这个宏:#pragma clang diagnostic ignored"-Wunused-function"

附上一个查找警告和宏关系的链接: http://fuckingclangwarnings.com


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

失控的未来

失控的未来

[美]约翰·C·黑文斯 / 仝琳 / 中信出版集团 / 2017-4-1 / 59.00元

【编辑推荐】 20年前,尼古拉•尼葛洛庞帝的《数字化生存》描绘了数字科技给人们的工作、生活、教育和娱乐带来的冲击和各种值得思考的问题。数字化生存是一种社会生存状态,即以数字化形式显现的存在状态。20年后,本书以一种畅想的形式,展望了未来智能机器人与人类工作、生活紧密相联的场景。作者尤其对智能机器人与人类的关系,通过假设的场景进行了大胆有趣的描述,提出了人工智能的未来可能会面临的一些问题。黑文......一起来看看 《失控的未来》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

SHA 加密
SHA 加密

SHA 加密工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换