Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSMutableDictionary key values

is it true that the key values for NSMutableDictionary can only be strings?

I was trying to use objects, but I am getting a warning.

like image 244
Mel Avatar asked Jan 22 '23 20:01

Mel


2 Answers

From the docs:

In general, a key can be any object (provided that it conforms to the NSCopying protocol—see below), but note that when using key-value coding the key must be a string (see Key-Value Coding Fundamentals).

What warning are you getting?

like image 79
Joshua Nozzi Avatar answered Feb 02 '23 20:02

Joshua Nozzi


You can use any object, but the object must implement -[NSObject hash], -[NSObject isEqual:], and the NSCopying protocol.

like image 44
Tom Dalling Avatar answered Feb 02 '23 21:02

Tom Dalling