unsafe_unretained和weak弱引用避免保留环(循环引用)区别
2017-12-15 17:51
357 查看
unsafe_unretained和weak都可以作为属性特质避免循环引用,他们的区别是:unsafe_unretained所修饰属性是不安全的,而且不归此事例拥有,如果系统已经把属性所指的那个对象回收,那么在回收的对象上调用方法会导致程序崩溃,而weak所修饰属性则会指向nil,这样就不会导致程序崩溃。所以委托对象属性使用weak修饰有两个作用,一个是避免循环引用,一个是委托对象回收时,继续使用弱引用避免程序崩溃。
相关文章推荐
- 强引用(strong)\弱引用(weak)\unsafe_unretained的区别
- property中的strong 、weak、copy 、assign 、retain 、unsafe_unretained 与autoreleasing区别和作用详解
- 建议慎用boost::weak_ptr来避免智能指针循环引用
- property中的strong 、weak、copy 、assign 、retain 、unsafe_unretained 与autoreleasing区别和作用详解
- iOS ARC下循环引用的问题 -举例说明strong和weak的区别
- iOS property中的strong 、weak、copy 、assign 、retain 、unsafe_unretained 与autoreleasing区别和作用详解
- ARC中strong、weak、unsafe_unretained的区别
- property中的strong 、weak、copy 、assign 、retain 、unsafe_unretained 与autoreleasing区别和作用详解
- property中的属性strong 、weak、copy 、assign 、retain 、unsafe_unretained 与autoreleasing区别和作用详解
- property参数strong 、weak、copy 、assign 、retain 、unsafe_unretained 与autoreleasing区别和作用详解
- copy,assign,strong,retain,weak,readonly,readwrite,nonatomic,atomic,unsafe_unretained的使用与区别
- property中的strong 、weak、copy 、assign 、retain 、unsafe_unretained 与autoreleasing区别和作用详解
- iOS 关键字 copy,assign,strong,retain,weak,readonly,readwrite,nonatomic,atomic,unsafe_unretained的使用与区别
- 不做从strong 到weak 的转换,如何避免循环引用
- 使用 weak–strong dance 技术来避免循环引用
- 使用 weak–strong dance 技术来避免循环引用
- iOS中 property中的属性strong 、weak、copy 、assign 、retain 、unsafe_unretained 与autoreleasing区别和作用详解
- property中的strong 、weak、copy 、assign 、retain 、unsafe_unretained 与autoreleasing区别和作用详解
- property中的strong 、weak、copy 、assign 、retain 、unsafe_unretained 与autoreleasing区别和作用详解
- __weak & __unsafe_unretained的用法以及区别