Remove duplicates in NSdictionary
Is there a way to remove duplicate (key-value) pairs from NSDictionary ? EDIT: My description was misleading, I have duplicate pairs e.g. key1-value1 key1-value1 key2-value2 key1-value1 etc.. Vladimir reversing key-value is not good idea because not all values can be keys. You can do it with: // dict is original dictionary, newDict new dictionary withot duplicates. NSMutableDictionary * newDict = [NSMutableDictionary dictionaryWithCapacity:[dict count]]; for(id item in [dict allValues]){ NSArray * keys = [dict allKeysForObject:item]; [newDict setObject:item forKey:[keys objectAtIndex:0]]; }