io strong,weak ,__unsafe_unretained, __autoreleasing
来源:互联网 发布:开淘宝店卖什么最赚钱 编辑:程序博客网 时间:2024/06/07 10:44
strong,weak 用来修饰属性。
strong 用来修饰强引用的属性;
@property (strong) SomeClass * aObject;
对应原来的
@property (retain) SomeClass * aObject; 和 @property (copy) SomeClass * aObject;
weak 用来修饰弱引用的属性;
@property (weak) SomeClass * aObject;
对应原来的
@property (assign) SomeClass * aObject;
__weak, __strong 用来修饰变量,此外还有 __unsafe_unretained, __autoreleasing 都是用来修饰变量的。
__strong 是缺省的关键词。
__weak 声明了一个可以自动 nil 化的弱引用。
__unsafe_unretained 声明一个弱应用,但是不会自动nil化,也就是说,如果所指向的内存区域被释放了,这个指针就是一个野指针了。
strong 用来修饰强引用的属性;
@property (strong) SomeClass * aObject;
对应原来的
@property (retain) SomeClass * aObject; 和 @property (copy) SomeClass * aObject;
weak 用来修饰弱引用的属性;
@property (weak) SomeClass * aObject;
对应原来的
@property (assign) SomeClass * aObject;
__weak, __strong 用来修饰变量,此外还有 __unsafe_unretained, __autoreleasing 都是用来修饰变量的。
__strong 是缺省的关键词。
__weak 声明了一个可以自动 nil 化的弱引用。
__unsafe_unretained 声明一个弱应用,但是不会自动nil化,也就是说,如果所指向的内存区域被释放了,这个指针就是一个野指针了。
__autoreleasing 用来修饰一个函数的参数,这个参数会在函数返回的时候被自动释放。
引申阅读:
Beginning ARC in iOS 5 Tutorial Part 1:http://www.raywenderlich.com/5677/beginning-arc-in-ios-5-part-1
ARC简介:http://blog.csdn.net/nicktang/article/details/6887569
http://blog.sina.com.cn/s/blog_7c336a8301012ilm.html
- io strong,weak ,__unsafe_unretained, __autoreleasing
- __strong、__weak、__unsafe_unretained和__autoreleasing修饰符
- strong weak
- Weak-Strong
- iOS内存管理-所有权修饰符:__strong, __weak/__unsafe_unretained, __autoreleasing
- Reference Soft Strong Weak
- Object-C Weak&Strong
- ARC Strong/Weak Variables
- strong和weak
- IOS strong 和 weak
- ios strong和weak
- obj-c strong weak
- iOS5 ARC strong weak
- strong与weak
- retain、strong、weak、assign
- strong和weak关键字
- strong,weak小记
- [ios] strong和weak
- ViewStub(惰性控件/延时加载)
- ios 360度旋转效果demo
- Windows异常处理
- [数据存储]属性列表plist
- js去除数组重复
- io strong,weak ,__unsafe_unretained, __autoreleasing
- 使用ssh登录freebsd
- [数据存储]CoreData
- [jtable]JDK SwingSet3 jtable源码
- USB介绍
- iphone ios uiview uilabel 边框,圆角,阴影实现
- NoSQL数据库:Redis内存使用优化与存储
- [数据存储]Sqlite
- Apache POI 3.8 (SXSSFWorkbook) - Unreadable Content