Frankly, it is rather a detail question.
Apples documentation of NSMutableDictionary https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/Reference/Reference.html states:
setObject:forKey:
Adds a given key-value pair to the dictionary.
- (void)setObject:(id)anObject forKey:(id)aKey
According to that the parameter forKey accepts any object. However, when I try to pass an NSNumber Incompatible pointer types sending 'NSNumber *' to parameter of type 'NSString *'
Aparently some NSString only is accepted as key.
For the time beeing I will convert my number to a string. In the end it is just a key. But does anybody know who is right? The documentation or the compiler?
You shouldn’t get that warning when using
setObject:forKey:. However, you will get that warning when using the similarly-namedsetValue:forKey:. The latter, while it appears similar in name, is part of the key-value coding system and thus only accepts anNSStringas the key.Here’s a sample program to demonstrate the difference.