Firstly I would like confirmation that I have understood NSCopying correctly …
In order to use a simple NSObject subclass as a key in an NSDictionary I must have it implement the NSCopying protocol. In the copied instance’s copyWithZone method I must alloc/init a new instance of my class, set its properties to be identical to the copied instance and return it.
Secondly, why does an NSDictionary use a copy of the instance added to it rather than the instance itself?
The subclass does not need to implement
NSCopyingif it is the object, the key should usually beNSStrings, which are copied.