我有以下字典
(
{
"_id" = 100;
status = 0;
student = {
"__v" = 0;
"_id" = 565b5fb94e8e3b72793407c0;
age = 9;
parentDetail = (
myson,
mywifesson
);
};
},
{
"_id" = 101;
status = 0;
student = {
"__v" = 0;
"_id" = 565dfc094afc74bb5a006491;
age = 9;
parentDetail = (
mywifesson
);
};
},
{
"_id" = 102;
status = 0;
student = {
"__v" = 0;
"_id" = 565e000f4afc74bb5a006493;
age = 9;
parentDetail = (
myson
);
};
}
)
我希望带有内部parentdetails的过滤器项包含字符串“ myson”。我尝试了以下谓词,但在过滤数组中获得了所有3个元素。但是实际上它应该只包含第一个和最后一个元素,而不包含第二个元素
parentid = @"myson"
[NSPredicate predicateWithFormat:@"ANY student.parentDetail CONTAINS[c] %@", parentid];
最佳答案
代替CONTAINS
尝试使用MATCHES
关于ios - NSPredicate用于包含内部数组的字典数组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34102757/