首页 > 其他 > 详细

不能使用weak修饰进行声明的类

时间:2016-07-01 13:18:37      阅读:204      评论:0      收藏:0      [点我收藏+]

These classes include NSTextViewNSFont and NSColorSpace; for the full list, see Transitioning to ARC Release Notes.

 

但是如果你真的想在这些类中使用weak进行修饰,可以使用不安全的修饰符unsafe_unretained

如:用unsafe_unretained修饰属性

  

@property (unsafe_unretained) NSObject *unsafeProperty;

__unsafe_unretained修饰变量
NSObject * __unsafe_unretained unsafeReference;

注意:虽然unsafe引用和weak的引用相似,都不会跟随对象的生命周期一直存在,但是weak被释放的时候是转变成空值的,而unsafe确不是,它会变成一个空指针,依然存在内存中,当发送信息给这个空指针的时候就会发生死机。

不能使用weak修饰进行声明的类

原文:http://www.cnblogs.com/lelun/p/5632533.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!