Reputation: 2251
I have entity employee_detail in coredata
name | rate | factor |
_______|______|________|
John | 3.2 | 4 |
Betty | 5.5 | 7 |
Betty | 2.1 | 2 |
Betty | 3.1 | 2 |
Edward | 4.5 | 5 |
John | 2.3 | 4 |
i want unique object base on attribute name
O/P should be
name | rate | factor |
_______|______|________|
John | 3.2 | 4 |
Betty | 5.5 | 7 |
Edward | 4.5 | 5 |
Upvotes: 2
Views: 592
Reputation: 16864
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"employee_detail"];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"employee_detail" inManagedObjectContext:self.managedObjectContext];
fetchRequest.resultType = NSDictionaryResultType;
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"name"]];
fetchRequest.returnsDistinctResults = YES;
NSArray *dictionaries = [self.managedObjectContext executeFetchRequest:fetchRequest error:nil];
NSLog (@"names: %@",dictionaries);
Upvotes: 2