I have NSarray
contains the list of Animals. The array contains a list of animals with repeated elements. I have to make an array with distinct values in the array.
Repeated values should be removed using NSPredicate
.
Here is my Code :-
NSArray *arrAnimals = [[NSArray alloc] initWithObjects:@"Cat",@"Rat",@"Fish",@"Cat",@"Fish",@"Cat",@"Cat",@"Bird",@"Fish",@"Cat",@"Frog", nil];
NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"distinct"]];
arrAnimals = [arrAnimals filteredArrayUsingPredicate:predicate];
Here I am using "distinct" keyword for sorting the array, but not able to find any solution. I have preferred many links.
Please resolve my problem.