我有NSDictionary
这样:
{
1 = A;
11 = AB;
19 = ABC;
2 = ABCD;
3 = ABCDE;
4 = ABCDEF;
5 = ABCDEFG;
6 = ABCDEFGH;
7 = ABCDEFGHI;
9 = ABCDEFGHIJ;
}
现在我想用谓词过滤Dictionary,以返回值开始的数组,例如用" ABCD"。 Key是一个ID(字符串),Value是string类型。
所以结果应该是
{
ABCD;
ABCDE;
ABCDEF;
ABCDEFG;
ABCDEFGH;
ABCDEFGHI;
ABCDEFGHIJ;
}
NSPredicate
看起来如何?
答案 0 :(得分:2)
Predicate将如下所示:
NSPredicate * predicate = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH[c] %@", @"ABCD"];