如何使用特定键来预测数组

时间:2014-01-02 08:39:24

标签: objective-c nspredicate

我只是想用Product_Id来预测我的数组。我试过这个

NSPredicate *pred=[NSPredicate predicateWithFormat:@"\"Product_Id\" ==%d",[[[_result valueForKey:@"Product_Id"] objectAtIndex:indexPath.row] integerValue]];
predicatedArray = [_likesArray filteredArrayUsingPredicate:pred]; 

_likesArray下面是字典数组

(
{
    DeviceLikeStatus = 1;
    Msg = "";
    ProductCount = 1;
    "Product_Id" = 116;
}
)

并不是预测任何事情,总是显示predicateArray为空。

1 个答案:

答案 0 :(得分:2)

不需要“在谓词中 试试

NSPredicate *pred=[NSPredicate predicateWithFormat:@"Product_Id ==%d",[[[_result valueForKey:@"Product_Id"] objectAtIndex:indexPath.row] integerValue]];