Core data 核心数据搜索列出某些变量等于

Core data 核心数据搜索列出某些变量等于,core-data,nsfetchrequest,Core Data,Nsfetchrequest,我已经有一段时间没有使用核心数据或SQL了,所以我甚至不记得该如何做,甚至不记得如何搜索它 我有一张物品清单 name | id | _______|______| John | 4 | Betty | 7 | Betty | 2 | Betty | 4 | Edward | 2 | Edward | 4 | John | 4 | 我想找到贝蒂和爱德华的身份证。 这应该返回2而不是4 有什么想法吗 非常感谢! Alex您将遇到属

我已经有一段时间没有使用核心数据或SQL了,所以我甚至不记得该如何做,甚至不记得如何搜索它

我有一张物品清单

  name | id   |
_______|______|
John   |  4   |
Betty  |  7   |
Betty  |  2   |
Betty  |  4   |
Edward |  2   |
Edward |  4   | 
John   |  4   |
我想找到贝蒂和爱德华的身份证。 这应该返回2而不是4

有什么想法吗

非常感谢!
Alex

您将遇到属性名
id
的问题,因此我使用
uid
。另外,请注意

NSArray *bettyIDs = [[allPersons filteredArrayUsingPredicate:
  [NSPredicate predicateWithFormat:@"name = %@", @"Betty"]  valueForKeyPath:@"uid"];
NSArray *edIDs    = [[allPersons filteredArrayUsingPredicate:
  [NSPredicate predicateWithFormat:@"name = %@", @"Edward"] valueForKeyPath:@"uid"];

NSArray *commonIDs = [bettyIDs filteredArrayUsingPredicate:
  [NSPredicate predicateWithFormat:@"self in %@", edIDs]];
// commonIDs --> @[@2, @4];

你是说只有贝蒂和爱德华是的,我就是这个意思。也许这样使用一个单独的表是不正确的。在mongo风格的db中,我只使用字符串数组。