Reputation: 305
how to know how many times a duplicate appears in my array ?
for (NSUInteger index = 0; index < count; index++)
{
NSDictionary *dico = [myArray objectAtIndex:index ];
NSString *exp = [dico objectForKey:@"name"];
NSLog(@"index %d : %@",index,exp);
}
this is my NSLog:
index 0 : Mike
index 1 : Peter
index 2 : Franck
index 3 : Peter
want to know where is my duplicates values.
thx
Upvotes: 0
Views: 1379
Reputation: 12405
If I am not wrong NSSet was designed to do this... try this..
NSSet *uniqueElements = [NSSet setWithArray:myArray];
for(id element in uniqueElements) {
// iterate here
}
Upvotes: 3