title: NSMutableDictionary with non-copyable UIView keys (using CFDictionary) crashes on iOS SDK 6, yet OK on 5.1
body: <p>So I was using TLMutableDictionaryNoncopiedKeys Category for NSMutableDictionary found <a href="http://www.cocoabuilder.com/archive/cocoa/214295-storing-values-in-dictionary-with-their-address-as-the-key.html" rel="nofollow">here</a> that allows using non-copyable objects as keys for dictionary (I need object-to-object mapping). All was good till I was told app crashes in iOS 6. So I downloaded XCode 4.5 with iOS 6 to test and it appears that there's some problem with CFDictionary functions. If I pass UIView as a key (in my category method) it crashes with:</p>
  
  <pre><code>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView copyWithZone:]: unrecognized selector sent to instance 0x719ff70'
  </code></pre>
  
  <p>More details from AppCode debugger:</p>
  
  <pre><code>objc_exception_throw
  -[NSObject(NSObject) doesNotRecognizeSelector:]
  __forwarding__
  _CF_forwarding_prep_0
  -[__NSDictionaryM setObject:forKey:]
  -[NSMutableDictionary __addObject:forKey:]
  CFDictionaryAddValue
  -[NSMutableDictionary(TLMutableDictionaryNoncopiedKeys) setObject:forUncopiedKey:]
  </code></pre>
  
  <p>I made a test project. It works well with iOS 5.1 Simulator, but crashes with 6.</p>
  
  <p>Could anyone shed some light on this?</p>
  
  <p>Full project is <a href="https://www.dropbox.com/s/djqgh7h79v3zsew/DictionaryTest.zip" rel="nofollow">here</a>. And here are some listings:</p>
  
  <p>Category:</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  
  @interface NSMutableDictionary (TLMutableDictionaryNoncopiedKeys)
  
  - (void)setObject:(id)anObject forUncopiedKey:(id)aKey;
  
  @end
  
  ----------------------------------------------------------------------
  
  #import "NSMutableDictionary+TLMutableDictionaryNoncopiedKeys.h"
  
  @implementation NSMutableDictionary (TLMutableDictionaryNoncopiedKeys)
  
  - (void)setObject:(id)anObject forUncopiedKey:(id)aKey
  {
      CFMutableDictionaryRef selfCF = (CFMutableDictionaryRef)self;
      Boolean keyAlreadySet = CFDictionaryContainsKey(selfCF, aKey);
      if (keyAlreadySet) {
          CFDictionaryReplaceValue(selfCF, aKey, anObject);
      }
      else {
          CFDictionaryAddValue(selfCF, aKey, anObject);
      }
  }
  
  @end
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>#import "NSMutableDictionary+TLMutableDictionaryNoncopiedKeys.h"
  ...
  NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  UIView *key = [[UIView alloc] init];
  [dict setObject:key forUncopiedKey:key];
  </code></pre>