Will Objective-C runtime release retained associative references for user?

后端 未结 1 454
执念已碎
执念已碎 2021-02-06 09:38

When some codes like this:

objc_setAssociatedObject (
  obj,
  &key,
  val,
  OBJC_ASSOCIATION_RETAIN
);

Do I need to call related

1条回答
  •  无人及你
    2021-02-06 10:26

    Associated objects will be released when the parent object is deallocated. See the documentation here, specifically this example:

    At point 1, the string overview is still valid because the OBJC_ASSOCIATION_RETAIN policy specifies that the array retains the associated object. When the array is deallocated, however (at point 2), overview is released and so in this case also deallocated.

    0 讨论(0)
提交回复
热议问题