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

黑马程序员--property参数

------Java培训、Android培训、iOS培训、.Net培训、期待与您交流! -------

1,set方法内存管理相关的参数

*retain:release旧值,retain新值(适用于OC对象类型)

*assign:直接赋值(默认,只用于非OC对象类型)

*copy: release旧值,copy新值

2,是否要产生set方法;

*readwrite:同时产生setter和getter的声明,实现(默认)

*readonly : 只会生产getter的声明,实现

@property (readonly) int height;

3,多线程管理:

*nonatomic: 性能高(一般用这个)

*atomic : 性能低(默认)

4,setter和getter方法的名称

*setter:决定了set方法的名称,一定要有个冒号

*getter: 决定了get方法的名称(一般用在bool类型的get方法)

@property (getter= isRich) BOOL rich;//返回BOOL类型的方法名一般以is开头

 

1,oc对象类型:

@property (nonatmotic, retain) 类名  * 属性名;

@property (nonatmotic, retain)  Car * car;

@property (nonatmotic, retain)  id car;

被retain过的属性,必须在dealloc方法中release

-(void) dealloc

{

    [_car release];

[super dealloc];

}

2,非OC对象类型(int\float\enum\struct)

@property (nonatmotic, assign)  类型名称 属性名;

@property (nonatmotic, assign)  int age;

 



原标题:黑马程序员--property参数

关键词:

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