Objective c NSPredicate不使用字典数组

Objective c NSPredicate不使用字典数组,objective-c,cocoa-touch,nsarray,nsdictionary,nspredicate,Objective C,Cocoa Touch,Nsarray,Nsdictionary,Nspredicate,我有一份格式如下的NSPredication:@“Status CONTAINS[cd]shipped” 我有一个字典数组,下面是一个示例: { { Category = "Category 4"; Comp = "Category 4"; Depth = 02; Grade = New; Length = 02; Location = "Thousand Oaks, CA";

我有一份格式如下的NSPredication:
@“Status CONTAINS[cd]shipped”

我有一个字典数组,下面是一个示例:

{
        {
        Category = "Category 4";
        Comp = "Category 4";
        Depth = 02;
        Grade = New;
        Length = 02;
        Location = "Thousand Oaks, CA";
        Name = "3ply Mat";
        Owner = "Owner 3";
        PUP = 2;
        Status = Shipped;
        "Unit Number" = 20110507113852351;
        Width = 02;
    },
        {
        Category = "Category 4";
        Comp = "Category 4";
        Depth = 02;
        Grade = New;
        Length = 02;
        Location = "Thousand Oaks, CA";
        Name = "3ply Mat";
        Owner = "Owner 3";
        PUP = 2;
        Status = Shipped;
        "Unit Number" = 20110516094641587;
        Width = 02;
    }
)

但它返回的是一个空数组。我做错了什么?谢谢

您可以对字符串使用关键字
匹配
包含
等。因为状态不是一个字符串,我想,你需要像这样检查它

[NSPredicate predicateWithFormat:@"Status = %d", Shipped];
你想要:

[NSPredicate predicateWithFormat:@"Status =[cd] 'shipped'"];
或:

您的问题是您的谓词格式已经发出了
,而它本应该发出
。缺少单引号意味着它试图将
[dictionary valueForKey:@“Status”]
[dictionary valueForKey:@“shipped”]
进行比较,而不是与字符串文字
@“shipped”
进行比较

[NSPredicate predicateWithFormat:@"Status =[cd] %@", @"shipped"];