在地址簿类应用上做项目。我需要预测地址簿联系人,结果看起来像这样
(
{
AddressKey = (
);
Email = (
);
"JobTitle_Name" = "";
"Organisation_Name" = "";
Phone = (
{
phoneNumber = "+919502266633";
"phone_type" = home;
},
{
phoneNumber = 9703570333;
"phone_type" = work;
},
{
phoneNumber = 91234512345;
"phone_type" = iPhone;
},
{
phoneNumber = 91239123;
"phone_type" = mobile;
}
);
"first_name" = Raviraja;
imageKey = "";
"last_name" = "";
serialNumberKey = 53;
source = Device;
}
)
需要使用phoneNumber键来预测数组。我试过这个
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY %K == %@",@"phoneNumber",[NSString stringWithFormat:@"%@",str]];
NSArray *array = [contactsArray filteredArrayUsingPredicate:predicate];
但是没有工作,尽管电话号码匹配。
帮帮我们。
答案 0 :(得分:1)
关键路径错误,应该是
[NSPredicate predicateWithFormat:@"ANY %K == %@",@"Phone.phoneNumber", ...]