使用Key过滤NSMutableDiction

时间:2016-09-20 10:05:32

标签: ios iphone xcode nspredicate

我需要在基于item_type= bad

的键值上过滤此NSMutableDictionary

我试过但没有工作

 NSPredicate *pred=[NSPredicate predicateWithFormat:@"(item_type == %@)", @"Good"];

    NSArray *resultArray = [[dummyDictionary allValues] filteredArrayUsingPredicate:pred];

    NSLog(@"resultArray:%@",resultArray);





{
    “Cat1” =     (
                {
            "image_item" = “a”;
            "item_type" = “Good”;
                  }
    );
    Cat2 =     (
                {
            "image_item" = “b”;
            "item_type" = Good;
                 },
                {
            "image_item" = “c”;
            "item_type" = Bad;
              },

    );
    Cat3 =     (
                {
            "image_item" = “d”;
            "item_type" = Good;
                 },
                {
            "image_item" = “e”;
            "item_type" = Bad;
                  },
       );
  }

需要输出NSMutableDictionary

{
    “Cat1” =     (

    );
    Cat2 =     (

                {
            "image_item" = “c”;
            "item_type" = Bad;
              },

    );
    Cat3 =     (

                {
            "image_item" = “e”;
            "item_type" = Bad;
                  },
       );
  }

注意:dummyDictionary是我从.plist获得的值

0 个答案:

没有答案