Objective-c Property define
来源:互联网 发布:iphone软件灰色删不掉 编辑:程序博客网 时间:2024/06/06 17:50
属性的定义(property)
@property (copy, nonatomic) NSString *title;
什么是assign,copy,retain之间的区别?
- assign: 简单赋值,不更改索引计数(Reference Counting)。
- copy: 建立一个索引计数为1的对象,然后释放旧对象
- retain:释放旧的对象,将旧对象的值赋予输入对象,再提高输入对象的索引计数为1
retain的实际语法为:
- (void)setName:(NSString *)newName { if (name != newName) { [name release]; name = [newName retain]; // name’s retain count has been bumped up by 1 }}
- 使用assign: 对基础数据类型 (NSInteger,CGFloat)和C数据类型(int, float, double, char, 等等)
- 使用copy: 对NSString
- 使用retain: 对其他NSObject和其子类
nonatomic关键字:
atomic是Objc使用的一种线程保护技术,基本上来讲,是防止在写未完成的时候被另外一个线程读取,造成数据错误。而这种机制是耗费系统资源的,所以在iPhone这种小型设备上,如果没有使用多线程间的通讯编程,那么nonatomic是一个非常好的选择。
- Objective-c Property define
- Objective-C #define 用法
- Objective-C #define 用法
- objective-c property
- objective-c property
- Objective-C 2.0 @property
- Objective C @property 参数
- objective-c @property 使用
- property 学习[Objective C]
- Objective-C @property关键字
- Objective-C语言--@property
- Objective-C中的@property
- Objective-C - @property参数
- Objective-C中的@property
- Objective-C property详解
- objective-c @property
- Objective-C中的@property
- Objective-C中的@property
- 静态库和动态库的区别
- 我擦!硬盘文件全被人删了!!
- 二级指针与二级数组汇总
- Eric5 IDE for Python在window是下安装
- 黑马程序员-反射的常用方法
- Objective-c Property define
- 博客开张
- C++模版树的建立
- Android Aidl实现进程间通信
- http://acm.hdu.edu.cn/showproblem.php?pid=1394&&线段树之求逆序数
- 黑马程序员-集合类继承树
- oracle 中禁用所有外键关联
- centos下安装openvswitch
- dede 时间标签,自定义样式