首页 > 其他 > 详细

一些常见的告警说明

时间:2015-10-08 00:23:48      阅读:1471      评论:0      收藏:0      [点我收藏+]

warning: default property attribute ‘assign‘ not
appropriate for non-GC object [-Wobjc-property-no-attribute]
[Note:]

  1. @property NSString *name,这样的申明会出现如下的warning:

“No ‘assign‘, ‘retain‘, or ‘copy‘ attribute is specified - ‘assign‘ is assumed”

“Default property attribute ‘assign‘ not appropriate for non-gc object”

这是因为在ARC支持的编译环境中,没有明确指出应该是assign还是retain或者是copy,缺省的是assign。而assign一般用于Scalar type(标量数据类型的描述,比如基本数据类型int, bool等),aggregate type(比如数组,结构体,类等)的描述应该用strong,让name从属的对象来持有他。

  1. @property (nonatomic, readonly) NSObject *object, 这样申明的readonly的属性,如果@synthesize会提示如下错误:

“ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute”

如果定义了ARC有效,那么必须要有所有者属性的定义;所以我们应该加上strong描述,就OK了。

 

一些常见的告警说明

原文:http://www.cnblogs.com/-cara/p/yi-xie-chang-jian-de-gao-jing-shuo-ming.html

(0)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!