IBOutlet and viewDidUnload under ARC

前端 未结 5 1035
野性不改
野性不改 2021-01-30 09:01

There is a similar question to this on SO here, however I just want to clarify something that wasn\'t fully explained there.

I understand that all delegates and outlets

5条回答
  •  难免孤独
    2021-01-30 09:50

    Starting from iOS 5 and OS X 10.7, weak will produce an automatic zeroing pointer. This means that when the pointed object is release, the pointer is automagically set to nil (for details see Zeroing Weak References in ARC).

    So, under iOS 5+ and OS X 10.7+, it is not useful to set the weak IBOutlet properties to nil manually in the viewDidUnload method: when the main view is unloaded, all its subviews will be released, so the related properties are set to nil.

提交回复
热议问题