您的位置:首页 > 移动开发 > Objective-C

About Setter and Getter

2011-12-10 14:05 369 查看
通过property声明和synthesize定义,Objective C自动生成了getter和setter。而且功能和上面的代码完全一样。

下面讲解一下property里声明的属性。

@property(nonatomic, retain) NSString *text 意为:我有个成员叫text,无需多线程保护,在setter里要使用retain/release过程。

@property(nonatomic, assign) int value 意为:我有个成员叫value,无需多线程保护,在setter里直接赋值就可以,不需要引用计数机制介入。

 if you wanna know more please click the following link . 
http://blog.csdn.net/ba_jie/article/details/6947451
by Tom Callon 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息