我有以下代码从Core Data
名为 StaffRecords 的实体中选择员工的姓名。我想选择记录Distinctly
,但这会选择所有记录。我如何制作结果Distinct
?
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"StaffRecords"];
[fetchRequest setPropertiesToFetch:@[@"StaffName"]];
[fetchRequest setReturnsDistinctResults:YES];
NSError *error = nil;
self.StaffNames = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
[self.tableView reloadData];