title: Cocoa's NSDictionary: why are keys copied?
body: <p>All objects used as keys in NS(Mutable)Dictionaries must support the NSCopying protocol, and those objects are copied when they're used in the dictionary.</p>
  
  <p>I frequently want to use heavier weight objects as keys, simply to map one object to another. What I really mean when I do that is effectively:</p>
  
  <pre><code>[dictionary setObject:someObject forKey:[NSValue valueWithPointer:keyObject]];
  </code></pre>
  
  <p>("When I come back and hand you this same key object instance again, get me that same value out.")</p>
  
  <p>...which is exactly what I end up doing to get around this design sometimes. (Yes, I know about NSMapTable in desktop Cocoa; but e.g. iPhone doesn't support this.)</p>
  
  <p>But what I don't <em>really</em> get is why copying the key is necessary or desirable in the first place. What does it buy the implementation or caller? </p>