Apple Interview Question
Software Engineer / DevelopersCountry: United States
Should it be?
Because NSDictionary's parameters for Key and Value are "id".
So I think the objects can be any object.
It can be C++ object. not NSObject.?
You can put any type of object into an NSDictionary. So while @"fred" is OK, 1 is not, as an integer is not an object. If you want to put a number in a dictionary, wrap it in an NSNumber.
Eg:
NSDictionary *header = [[NSDictionary alloc]initWithObjectsAndKeys:@"fred", @"title", [NSNumber numberWithInteger:1], @"count", nil];
The object must be either a NSObject or subclass it. Therefore you cannot store primitive types.
- Ozan Eren Bilgen October 19, 2012