This can be done using "SELF[index]" in the predicate:
NSArray *array = @[
@[@"databaseVersion", @13],
@[@"lockedSetId", @100],
@[@"databaseVersion", @55],
@[@"foo", @"bar"]
];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF[0] == %@", @"databaseVersion"];
NSArray *filtered = [array filteredArrayUsingPredicate:pred];
NSLog(@"%@", filtered);
Output:
(
(
databaseVersion,
13
),
(
databaseVersion,
55
)
)
Or you can use a block-based predicate:
NSPredicate *pred = [NSPredicate predicateWithBlock:^BOOL(NSArray *elem, NSDictionary *bindings) {
return [elem[0] isEqualTo:@"databaseVersion"];
}];
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…