如何将此SQL查询转换为Core Data

时间:2013-02-19 09:33:18

标签: objective-c cocoa core-data nspredicate

如何将sql查询转换为谓词或获取请求,

select a.name 
from a 
group by a.name;

1 个答案:

答案 0 :(得分:1)

这是一个可能的解决方案:

NSFetchRequest* request = [NSFetchRequest fetchRequestWithEntityName:@"a"];
[request setPropertiesToFetch:@[@"name"]];
[request setPropertiesToGroupBy:@[@"name"]];
[request setResultType:NSDictionaryResultType];