iOS开发之strong,retain,nonatomic等修饰词的小结
来源:互联网 发布:淘宝售前售后客服 编辑:程序博客网 时间:2024/05/21 01:52
一、ARC和非ARC的混编
1、在ARC下编译非ARC的文件,打开工程,target->Build Phases->Compile Source找到非ARC模式的文件,双击空白处,添加:-fno-objc-arc,如果是多个文件,只要全选,然后只要双击空白处,添加上面一条语句,就可以完成所有文件的处理,如下图:
2、在MRC模式下编译ARC文件,同理,如上所述,但是要添加语句:-fobjc-arc即可。
如下图:
二、retain、assign、strong、weak、nonatomic的区别
1、nonatomic和atomic的区别
atomic,原子性:
保证多线程的安全,目的是保护变量在为完成的时候,被另一个线程读取,造成数据错误,会消耗一定的系统资源。
noatominc,非原子性:禁止多线程,保护变量,可以提高 系统的性能。
2、strong和weak
strong:强引用,用该属性创建的变量,对对象持有所有权。
weak:弱引用,用改属性创建的变量,对对没有持有权,当不用的时候,会自动赋值为nil
3、retain和assign
retain:当变量为指针类型的时候,需要retain修饰,使用setter方法(赋值)的时候,引用级数增加1。
assign:修饰非指针类型和id类型的变量,如NSInteger,CGFloat,或者delegate。
0 0
- iOS开发之strong,retain,nonatomic等修饰词的小结
- IOS属性(@property)的修饰词assign、weak、strong、retain、copy、nonatomic、atomic、readonly、readwrite解释、以及一部分内存优化方法
- IOS中属性的关键修饰词:strong weak assign copy retain等。。
- iOS开发之assign retain copy strong weak 的区别
- iOS开发之详解@property属性(copy,strong,weak,nonatomic,readwrite等)
- 个人理解的IOS开发Objective-C中的属性readwrite,readonly,retain,assign,copy,nonatomic,strong,weak.
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- iOS开发中@property的属性weak nonatomic strong readonly等介绍
- 添加第三方类库造成的linker command failed with exit code 1 (use -v to see invocation)的错误调试
- Third Party Jars for Storm Cluster
- spring-framework-4.1.6 mvc整合commons-dbutils-1.6注解式事务
- [HAOI2010]最长上升子序列长度
- iOS —— SQLite 简介 (一)
- iOS开发之strong,retain,nonatomic等修饰词的小结
- Java垃圾回收(二) 堆内存的分代回收
- 设置控件圆角,只设置上面两个角的圆角(任意角)
- ubuntu12.04下安装java-7-openjdk-amd64
- linux sed命令详解
- 大端序、小端序union分析
- java hashcode和equal总结
- C++实现简单选择排序
- iOS —— SQLite3 参数绑定和重执行已编译语句 (二)