samedi 27 juin 2015

NSDictionary and NSPredicate

I am using a NSDictionary that itself contains dictionaries some keys and its values which are arrays.The format is like so:

{
    0 =     {
        0 =         (
                     3,
                     0,
                     3
                     );
        1 =         (
                     2,
                     0,
                     2
                     );
    };
    1 =     {
        0 =         (
                     1,
                     1,
                     1
                     );
        1 =         (
                     1,
                     1,
                     2
                     );
    };
};

I'm using NSPredicate to searach a dictionary within the dictionary to get the array that contains value 3 at index 0. like so:

inside = [VDictionary objectForKey:[NSNumber numberWithInt:0];
NSPredicate *p = [NSPredicate predicateWithFormat:@"%@[SELF][0] == '3'", inside];

It works but the problem is that the above only searches the dictionary with key 0, I want to search all the dictionaries not just one at a time.

How do I use NSPredicate to search all the dictionaries within a dictionary and get the array that contains the value 3 at index 0?

Aucun commentaire:

Enregistrer un commentaire