ios - Initialize NSMutableDictionary -
i developing ios application in want use nsmutabledictionary
. doing converting java code objectivec.
so in java have this:
map<string, classa> dict1 = new hashmap<>(); map<integer,character> dict2 = new hashmap<>(); map<integer, map<string,string>> dict3 = new hashmap<>();
can please guide me obj-c equivalent code above 3 lines using nsmutabledictionary
, how can set , pairs in/from dictionaries.
the objective-c collection classes not typed 3 dictionaries created using:
nsmutabledictionary *dictx = [nsmutabledictionary new];
in order populate dictionary use [nsmutabledictionary setobject:forkey:]
:
[dict1 setobject:classainstance forkey:@"key1"]; [dict2 setobject:[nsstring stringwithformat:@"%c", character] forkey:@(1)]; [dict3 setobject:@{ @"innerkey" : @"innervalue" } forkey:@(2)];
etc.
Comments
Post a Comment