Maintaining the order while iterating a NSDictionary

前端 未结 3 1896
春和景丽
春和景丽 2021-01-28 01:49

I have a NSDictionary which im iterating and Im saving the datas to core data as follows,

NSDictionary *details = [valueDict objectForKey:@\"shipment_master\"];
         


        
3条回答
  •  北恋
    北恋 (楼主)
    2021-01-28 02:23

    NSMutableDictionary is not ordered. There is nothing you can do to guarantee the order of keys because NSDictionary makes no attempt to preserve any particular ordering. To go over a dictionary in a particular order, you have to make an NSArray of the keys that is in the order you want, then iterate that and fetch the corresponding values.

提交回复
热议问题