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
See the BMNullableArray class, which is part of my BMCommons framework for a full solution to this problem.
This class allows nil objects to be inserted and has the option to weakly reference the objects it contains (automatically nilling them when they get deallocated).
The problem with automatic removal (which I tried to implement) is that you get thread-safety issues, since it is not guaranteed at which point in time objects will be deallocated, which might as well happen while iterating the array.
This class is an improvement over NSPointerArray, since it abstracts some lower level details for you and allows you to work with objects instead of pointers. It even supports NSFastEnumeration to iterate over the array with nil references in there.