理解assign,copy,retain
2016-03-02 17:06
363 查看
今天学习这方面知识的时候看到一篇文章讲的挺通俗易懂的。
转载过来:http://my.oschina.net/openlab/blog/89354
ARC中的strong相当于非ARC中的retain
retain是指针拷贝,copy是内容拷贝。
1. atomic:默认是有该属性的,这个属性是为了保证在多线程情况,编译器会自动生成一些互斥加锁代码,避免该变量的读写不同步问题。
nonatomic:会让编译器少生成一些互斥加锁代码,可以提高效率。
2.readwrite:这个属性是默认的,会自动为你生成存取器。
readonly:只生成getter,不会有setter方法
3.strong:强引用,其存亡直接决定了所指对象的存亡。如果不存在指向一个对象的引用,并且此对象不再显示在列表中,则此对象会被从内存中释放。
weak:弱引用,不决定对象的存亡。只要没有强引用,还是会清除。
转载过来:http://my.oschina.net/openlab/blog/89354
ARC中的strong相当于非ARC中的retain
retain是指针拷贝,copy是内容拷贝。
1. atomic:默认是有该属性的,这个属性是为了保证在多线程情况,编译器会自动生成一些互斥加锁代码,避免该变量的读写不同步问题。
nonatomic:会让编译器少生成一些互斥加锁代码,可以提高效率。
2.readwrite:这个属性是默认的,会自动为你生成存取器。
readonly:只生成getter,不会有setter方法
3.strong:强引用,其存亡直接决定了所指对象的存亡。如果不存在指向一个对象的引用,并且此对象不再显示在列表中,则此对象会被从内存中释放。
weak:弱引用,不决定对象的存亡。只要没有强引用,还是会清除。
相关文章推荐
- sqoop连接mysql出现Failed to list databases com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
- 76.You need to display the first names of all customers from the CUSTOMERS table that contain the
- pod的SDK报错,Linker command failed with exit code1(use -v to see invocation)
- pod的SDK报错,Linker command failed with exit code1(use -v to see invocation)
- AIX 6.1 异步 I/O 的 配置与性能评估
- 使用RAID进行磁盘管理
- AIX 6.1 异步 I/O 的 配置与性能评估
- studio中install_failed_dexopt 解决
- 环信SDK报错处理方法obtain an updated library from the vendor, or disable bitcode for this target. for archit
- 环信SDK报错处理方法obtain an updated library from the vendor, or disable bitcode for this target. for archit
- Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift 论文翻译
- io.h头文件下的一些函数 http://blog.csdn.net/babygjx/article/details/5740038
- 设计模式 ( 十二 ) 职责链模式(Chain of Responsibility)(对象行为)
- .NET程序连接OPC Server时出错 对 COM 组件的调用返回了错误 HRESULT E_FAIL
- assign©&ratain, strong&weak, nonatomic
- 人工智能2:智能Agent
- 人工智能1:基本概念
- BIT2014级软件学院程序设计-09 Easier Done Than Said
- 解决INSTALL_FAILED_VERSION_DOWNGRADE
- opendir failed, Permission denied 不ROOT