Frage

I have a NSDictionary like so:

{
    1 = A;
    11 = AB;
    19 = ABC;
    2 = ABCD;
    3 = ABCDE;
    4 = ABCDEF;
    5 = ABCDEFG;
    6 = ABCDEFGH;
    7 = ABCDEFGHI;
    9 = ABCDEFGHIJ;
}

Now I want to filter the Dictionary with a predicate to return an array where the value begins e.g. with "ABCD". The Key is an ID (string) and Value is of type string.

So the result should be

{
    ABCD;
    ABCDE;
    ABCDEF;
    ABCDEFG;
    ABCDEFGH;
    ABCDEFGHI;
    ABCDEFGHIJ;
}

How does the NSPredicate has to look like?

War es hilfreich?

Lösung

Predicate will look like this:

NSPredicate * predicate = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH[c] %@", @"ABCD"];
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top