Why 'initWithObjectsAndKeys:' doesn't throw a casting warning? (NSDictionary)
Posted
by rubdottocom
on Stack Overflow
See other posts from Stack Overflow
or by rubdottocom
Published on 2010-03-26T07:16:23Z
Indexed on
2010/03/26
7:23 UTC
Read the original article
Hit count: 719
Sorry if the question isn't correct, I'm very new in Objective-C.
I understand why this code throw the Warning: "warning: passing argument 1 of 'initWithObjectsAndKeys:' makes pointer from integer without"
NSDictionary *dictNames =
[[NSDictionary alloc] initWithObjectsAndKeys:
3, @"",
4, @"",
5, @"",nil];
Keys and Values of a NSDictionary must be NSObject and not fundamental types, like the integers 3, 4 and 5. (Correct me if necessary).
But I don't understand why this warning dissapears with the only "correct typing" of the first Key.
NSDictionary *dictNames =
[[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInteger:3], @"",
4, @"",
5, @"",nil];
It's because NSDictionary assumes the type of the other Keys? Is correct this manner of initialization?
© Stack Overflow or respective owner