Xcode一些Analyze分析的错误

2019-04-07  本文已影响0人  参天草

1.错误:User-facing text should use localized string macro

 给label赋值的时候,提示

面向用户的文本应该使用本地化的字符串宏

此为代码中配置了本地化,面向用户的应该用字符串宏,而我们直接赋值为汉字.

解决方法:

2.Property of mutable type 'NSMutableArray' has 'copy' attribute; an immutable object will be stored instead;

因为copy 通常会返回不可变的副本。

因此,当一个NSMutableArray设置copy,会返回一个NSArray类型的包含同样数据的结构。

此处建议用strong来修饰mutableArray.

3.The 'viewWillDisappear:' instance method in UIViewController subclass 'xxxxx' is missing a [super viewWillDisappear:] call;这个错误提示是:重写父类中的实例方法viewWillDisappear,没有在子类中调用,从下图我们可以看到确实是这样,-(void)viewWillDisappear:(BOOL)animated方法内部调用的是[super viewDidAppear:animated];这种是很低级的错误.

       4.Value stored to 'xxxxx' is never read,声明的变量没有被用到

5. API Misuse 接口应用错误,这里主要针对的是系统提供的接口

从下图中我们可以看到,_cachedStatements是一个字典,字典是不允许出现nil对象的,所以存数据之前我们要做容错判断.

        改完后就不再提示了

上一篇下一篇

猜你喜欢

热点阅读