从nib文件关联的IBOutlet声明为weak,而不是strong

之前一直不理解标题的原理,只是知道strong和weak的区别,现MAC Programming Guard中的一个Tutorial——"Your First Mac App"中的一句话惊醒梦中人啊!

The property specifies the strong attribute rather than the weak attribute, indicating that the Track object is owned by the app delegate. As long as the app delegate references it, the Track object won’t go away. The outlet property declarations you created earlier use the weak attribute because the corresponding UI elements are contained in the view hierarchy that is owned by the window, not the app delegate. The window and its view hierarchy can go away independent of the app delegate.


从IB中的UI对象的继承关系在UIView的中,而不是在IBOutlet所在的类中。该UI控件的从创建、使用到消亡,都是UIView的继承关系中保证,而不需要IBOutlet中去管理它的声明周期。所以声明成weak的而不是strong。得意

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值