title: Collections of zeroing weak references under ARC
body: <p>How can I get an array of <strong>zeroing weak references</strong> under ARC? I don't want the array to retain the objects. And I'd like the array elements either to remove themselves when they're deallocated, or set those entries to nil.</p>
  
  <p>Similarly, how can I do that with a dictionary? I don't want the dictionary to retain the values. And again, I'd like the dictionary elements either to remove themselves when the values are deallocated, or set the values to nil. (I need to retain the keys, which are the unique identifiers, at least until the corresponding values are deallocated.)</p>
  
  <p>These two questions cover similar ground:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/9336288/nsarray-of-weak-references-to-objects-under-arc">NSArray of weak references to objects under ARC</a></li>
  <li><a href="https://stackoverflow.com/questions/11928730/having-a-list-of-unretained-id-objects/11928840#11928840">Having a list of unretained id objects?</a></li>
  </ul>
  
  <p>But neither is asking for <strong>zeroing references</strong>.</p>
  
  <p>Per the documentation, neither NSPointerArray nor NSHashMap support weak references under ARC. NSValue's nonretainedObjectValue will not work either, as it is non-zeroing.</p>
  
  <p>The only solution I see is to create <em>my own</em> NSValue-like wrapper class with a <code>(weak)</code> property, as <a href="https://stackoverflow.com/a/13351665/893113">this answer mentions, near the end</a>. Is there a better way I'm not seeing?</p>
  
  <p>I'm developing for OS X 10.7 and iOS 6.0.</p>