NSArray of weak references (__unsafe_unretained) to objects under ARC

前端 未结 12 748
南旧
南旧 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:24

    If you do not require a specific order you could use NSMapTable with special key/value options

    NSPointerFunctionsWeakMemory

    Uses weak read and write barriers appropriate for ARC or GC. Using NSPointerFunctionsWeakMemory object references will turn to NULL on last release.

提交回复
热议问题