Nsmutablearray *dictoarray = [Nsmutablearray array];
Nsmutabledictionary *arraytodic = [Nsmutabledictionary dictionary];
Nsdictionary *dic = @{@ "1": @ "one", @ "2": @ "", @ "3": @ "three"};
Dictionary to Array
[DIC enumeratekeysandobjectsusingblock:^ (ID _nonnull key, id _nonnull obj, BOOL * _nonnull stop) {
[Dictoarray addobject:[nsstring stringwithformat:@ "%@:%@", Key,obj]];
}];
NSLog (@ "dictoarray====%@", Dictoarray);
Array to Dictionary
[Dictoarray enumerateobjectsusingblock:^ (id _nonnull obj, nsuinteger idx, BOOL * _nonnull stop) {
NSLog (@ "Obj===%@===idx===%lu", obj, (unsigned long) idx);
Nsarray *array = [obj componentsseparatedbystring:@ ":"];//split string
[Arraytodic setobject:array[1] forkey:array[0];
}];
NSLog (@ "arraytodic====%@", arraytodic);
dictoarray==== (
"1:one",
"2:two",
"3:three"
)
arraytodic===={
1 = one;
2 = both;
3 = three;
}
Dictionary to Array to dictionary