NSPredicate与子数组

我正在寻找以下类型的数据结构:

 {
     author =“作者1”;
     channelIds =(
         7
     );
 },
 {
     author =“作者2”;
     channelIds =(
         7,
         1
     );
 },
 ,
 {
     author =“作者3”;
     channelIds =(
         3,
         7
     );
 }

我想构建一个由channeldIds = 7的所有项组成的数组。

我正在按照以下谓词的方式尝试:

NSPredicate * filterById = [NSPredicate predicateWithFormat:@"channelIds[0] = '7'"]; 
  • 我怎么能在这里做我想做的事?
  • 我可以拥有x个channelIds,有没有办法在谓词中迭代?

Tia,S。

更轻松:

 NSPredicate *filterById = [NSPredicate predicateWithFormat:@"channelIds CONTAINS %@", @"7"]; 

这假设您的channelIds值是一个字符串数组。 如果它是一个数字数组( NSNumber ),那么你的格式字符串就是@"channelIds CONTAINS 7"