I have some values pulled from a web service giving me a bool value for a key. I did it this way, but feel like it is repeating without need. How can I refactor this?
Please note that the key on the dictionary has the same name as the object property.
for (NSDictionary *itemDicto in switchesArray) {
if ([[itemDicto objectForKey:@"id"]isEqualToString:@"FindBookMeeting"]) {
currentAppswitches.FindBookMeeting = [[itemDicto objectForKey:@"value"]boolValue];
}
if ([[itemDicto objectForKey:@"id"]isEqualToString:@"FindCapabilityLocate"]) {
currentAppswitches.FindCapabilityLocate = [[itemDicto objectForKey:@"value"]boolValue];
}
if ([[itemDicto objectForKey:@"id"]isEqualToString:@"FindDesk"]) {
currentAppswitches.FindDesk = [[itemDicto objectForKey:@"value"]boolValue];
}
if ([[itemDicto objectForKey:@"id"]isEqualToString:@"FindEmployeeLocate"]) {
currentAppswitches.FindEmployeeLocate = [[itemDicto objectForKey:@"value"]boolValue];
}
if ([[itemDicto objectForKey:@"id"]isEqualToString:@"Help"]) {
currentAppswitches.Help = [[itemDicto objectForKey:@"value"]boolValue];
}
if ([[itemDicto objectForKey:@"id"]isEqualToString:@"ReportProblemIT"]) {
currentAppswitches.ReportProblemIT = [[itemDicto objectForKey:@"value"]boolValue];
//test ok
//currentAppswitches.ReportProblemIT = NO;
}
if ([[itemDicto objectForKey:@"id"]isEqualToString:@"ReportProblemProperty"]) {
currentAppswitches.ReportProblemProperty = [[itemDicto objectForKey:@"value"]boolValue];
}
if ([[itemDicto objectForKey:@"id"]isEqualToString:@"Settings"]) {
currentAppswitches.Settings = [[itemDicto objectForKey:@"value"]boolValue];
}
}