IN 运算符是否适用于过滤 SBElementArrays?我一直在尝试使用它,但它总是返回一个 NULL 数组。
我的代码(hexArray 通常会有更多元素):
SBElementArray *musicTracks = [libraryPlaylist fileTracks];
hexArray = [NSArray arrayWithObject: @"3802BF81BD1DAB10"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY %K IN %@",@"persistentID",hexArray];
NSLog(@"%@", [[musicTracks filteredArrayUsingPredicate:predicate] valueForKey:@"persistentID"]);
NSLog(@"%@", hexArray);
NSLog(@"%@", predicate);
输出:
2013-05-26 12:59:29.907 test[1226:403] (null)
2013-05-26 12:59:29.907 test[1226:403] (3802BF81BD1DAB10)
2013-05-26 12:59:29.908 test[1226:403] ANY persistentID IN {"3802BF81BD1DAB10"}
我尝试将谓词设置为:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY %K == %@",@"persistentID",hexArray];
输出:
2013-05-26 13:03:04.629 test[1258:403] (3802BF81BD1DAB10)
2013-05-26 13:03:04.630 test[1258:403] (3802BF81BD1DAB10)
2013-05-26 13:03:04.630 test[1258:403] ANY persistentID == {"3802BF81BD1DAB10"}
这很好用。但我想要 IN 功能。