I have a NSDictionary which im iterating and Im saving the datas to core data as follows,
NSDictionary *details = [valueDict objectForKey:@"shipment_master"];
for (NSDictionary *response in details) {
NSManagedObjectContext *context = [self managedObjectContext];
// remove all rows
[context performBlockAndWait:^{
// add new row(s)
NSManagedObject *master = [NSEntityDescription insertNewObjectForEntityForName:@"ShipmentMaster" inManagedObjectContext:context];
NSError *error;
[master setValue:[details objectForKey:response] forKey:@"values"];
// save MOC
if ([context hasChanges]) {
(void)[context save:&error];
}
}];
}
The problem is that the order is being changed while looping the nsdictionary. For instance a comes after b then c ,d etc in the dictionary but when Im iterating it and saving it, the order is being changed, How can I maintain the order?