I have an array, as
(John, Jane, John)
I want to get duplicates,as well as original elements of array like
(John,John) I am able to get single occurance from code here
NSArray *names = [NSArray arrayWithObjects:@"John", @"Jane", @"John", nil];
NSCountedSet *set = [[NSCountedSet alloc] initWithArray:names];
for (id item in set)
{
NSLog(@"Name=%@, Count=%lu", item, (unsigned long)[set countForObject:item]);
if((unsigned long)[set countForObject:item]>1){
NSLog(@"of repeated element-----=%@",item);
}
}
"Name of repeated element-----John" but i want all occurences of repeated element like "Name of repeated element-----John,John" .
Try this Using NSPredicate: