NSMutableArray *dicToArray = [NSMutableArray array];
NSMutableDictionary *arrayToDic = [NSMutableDictionary dictionary];
//字典转数组
NSDictionary *dic = @{@"1":@"one",@"2":@"two",@"3":@"three"};
[dic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
[dicToArray addObject:[NSString stringWithFormat:@"%@:%@",key,obj]];
}];
NSLog(@"dicToArray====%@",dicToArray);
[dicToArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSLog(@"obj===%@===idx===%lu",obj,(unsigned long)idx);
NSArray *array = [obj componentsSeparatedByString:@":"];//分割字符串
[arrayToDic setObject:array[1] forKey:array[0]];
}];
NSLog(@"arrayToDic====%@",arrayToDic);
dicToArray====(
"1:one",
"2:two",
"3:three"
)
arrayToDic===={
1 = one;
2 = two;
3 = three;
}