How to create an NSDictionary in Objective-C?
Objective-C the correct, typed way of creating a dictionary.
The following has a strongly typed
NSString and the
You should always set the types where you can, because by making it strongly typed the compiler will stop you from making common errors and it works better with Swift:
NSDictionary<NSString *, NSNumber *> *numberDictionary;
but in the case above, we need to store an array in the dictionary, so it will be:
NSDictionary<NSString *, id> *dataDictionary;
which allows the value to be of any type.