Objective c 在数组中搜索值

Objective c 在数组中搜索值,objective-c,cocoa-touch,Objective C,Cocoa Touch,我有一个具有以下值的数组: ( ( John, "John.plist", active ), ( Lucas, "Lucas.plist", inactive ) ) 我需要的是获取活动节点的索引 这是我的密码: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@",@"active"]; NSArray *re

我有一个具有以下值的数组:

(
    (
      John,
      "John.plist",
      active
    ),
    (
      Lucas,
      "Lucas.plist",
      inactive
    )
)
我需要的是获取活动节点的索引

这是我的密码:

 NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@",@"active"];
 NSArray *results = [accounts filteredArrayUsingPredicate:predicate];

 NSLog(@"%@", results);

这给了我错误。发生了什么?谢谢

解决此问题的一种方法如下:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@ in self",@"active"];
NSArray *results = [accounts filteredArrayUsingPredicate:predicate];

NSLog(@"%@", results);

虽然更好的解决方案是使用键/值对而不是单个字符串的字典,但数组中有数组。“活动”在
main数组[0][2]
中,我知道。但是这个数组是动态的。这就是我需要搜索的原因。我想到的第一件事是对外部数组使用一个循环,比如计数器是
I
,然后查看子数组[I],得到
活动的索引。再存储一次,没有更简单的方法吗?