Collections of zeroing weak references under ARC

前端 未结 8 680
粉色の甜心
粉色の甜心 2020-12-23 14:05

How can I get an array of zeroing weak references under ARC? I don\'t want the array to retain the objects. And I\'d like the array elements either to remov

8条回答
  •  没有蜡笔的小新
    2020-12-23 14:52

    I just create non-threadsafe weak ref version of NSMutableDictionary and NSMutableSet. Code here: https://gist.github.com/4492283

    For NSMutableArray, things is more complicated because it cannot contain nil and an object may be added to the array multiple times. But it is feasible to implemented one.

提交回复
热议问题