星空网 > 软件开发 > 操作系统

一些常见的告警说明

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了。




原标题:一些常见的告警说明

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流