NSArray of weak references (__unsafe_unretained) to objects under ARC

前端 未结 12 741
南旧
南旧 2020-11-27 11:26

I need to store weak references to objects in an NSArray, in order to prevent retain cycles. I\'m not sure of the proper syntax to use. Is this the correct way?



        
12条回答
  •  星月不相逢
    2020-11-27 12:07

    No, that's not correct. Those aren't actually weak references. You can't really store weak references in an array right now. You need to have a mutable array and remove the references when you're done with them or remove the whole array when you're done with it, or roll your own data structure that supports it.

    Hopefully this is something that they'll address in the near future (a weak version of NSArray).

提交回复
热议问题