I’m getting a compiler warning when using the following code:
for(int i=0; i<[mutableTempArray count]; i++){
//...
[tempInfoDictionary setValue:i forKey:@"tag"];
//...
}
The warning is:
passing argument 1 of ‘setValue:forKey:’ makes pointer from integer without a cast
What am I doing wrong here?
Collections in Objective-C can only hold objects, so you’ll need to wrap
iin anNSNumberobject.iitself is a primitive type, not an object, so it can’t be put inside a collection object.The first argument to
setValue:forKey:is expected to be of pointer type, whichiitself clearly isn’t.I suggest using the
setObject:forKey:method on anNSDictionaryinstead ofsetValue:forKey:, because it states your intentions better. You’re not only storing a value, you’re storing an object