IBOutlet and viewDidUnload under ARC

前端 未结 5 789
野性不改
野性不改 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:39

    Just doing a bit of research...

    As I understand it, weak is similar to assign, in that they're both weak references.

    However, assign does not create a zeroing reference. i.e. if the object in question is destroyed, and you access that property, you WILL get a BAD_ACCESS_EXCEPTION.

    Weak properties are automatically zeroed (= nil) when the object it is referencing is destroyed.

    In both cases, it is not necessary to set property to nil, as it does not contribute to the retain count of the object in question. It is necessary when using retain properties.

    Apparently, ARC also introduces a new "strong" property, which is the same as "retain"?

    Research done here

提交回复
热议问题