Merge two NSDictionary in one NSDictionary ( if keyvalues are same )
NSMutableDictionary *combined = [your_nsdictionary mutableCopy];
for(NSString *key in [combined allKeys])
{
NSString *breakfastDate = [your_nsdictionary valueForKey:key];
NSString *dinnerDate = [your_nsdictionarytwo objectForKey:key];
if(dinnerDate){
[combined setObject:[NSString stringWithFormat:@"%@,%@",breakfastDate, dinnerDate] forKey:key];
} else {
[combined setObject:[NSString stringWithFormat:@"%@,0",breakfastDate] forKey:key];
}
}
NSLog(@"Combine %@",combined);
No comments:
Post a Comment