I'm using NSMapTable
in a number of places in an iOS 6 project, and would like to be able to use the new dictionary subscripting style for accessing objects. (NSMapTable
behaves mostly like an NSMutableDictionary
, but can be configured with various memory management options for the keys and values it stores. More background in this StackOverflow question.)
The compiler reports this when attempting to use subscripting syntax on an NSMapTable
instance:
Expected method to read dictionary element not found on object of type 'NSMapTable *'.
How can I use a category to extend NSMapTable
to allow the new NSDictionary
-style subscripting?
NSMapTable
doesn't have subscripting for a reason. For example, if you've got aNSMapTable
usingNSPointerFunctionsStrongMemory
, why would you need to conform toNSCopying
? This category actually cripplesNSMapTable
to a dictionary-like collection. – Cabot