Saturday, May 17, 2014

Using an Object as a NSDictionary key triggers NSCopying warning

Getting the warning:  Sending 'SomeClass *__strong' to parameter of incompatible type 'id'

Usually the NSDictionary key is a string, but it can also be an object as long as it conforms to the NSCopying protocol.  The class just needs to be able to respond to the copy and copyWithZone methods so it's safe to cast it according to this SO answer:

http://stackoverflow.com/questions/12525324/unable-to-use-class-as-a-key-in-nsdictionary/12525479#12525479

No comments:

Post a Comment