Warning - unable to find template matching predicate

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Warning - unable to find template matching predicate

    Edit: Problem bereits gelöst. :)

    Hallo Leute,

    ich verstehe einfach nicht warum ich diese Fehlermeldung bekomme:

    Quellcode

    1. Warning - unable to find template matching predicate (name = 'test' AND state = 'test2')


    Im Interface Builder habe ich einen NSPredicateEditor ohne NSPredicateEditorRowTemplate platziert. Er ist über ein Binding mit dem Controller verbunden. Sein "Value" Attribut ist mit einem String einer CoreData Entity verbunden.

    Im Controller erzeuge ich die NSPredicateEditorRowTemplates folgendermaßen:

    Quellcode

    1. NSArray *keyPaths = [NSArray arrayWithObjects:[NSExpression expressionForKeyPath:@"name"],
    2. [NSExpression expressionForKeyPath:@"state"], nil];
    3. NSArray *operators = [NSArray arrayWithObjects:[NSNumber numberWithInteger:NSEqualToPredicateOperatorType],
    4. [NSNumber numberWithInteger:NSNotEqualToPredicateOperatorType],
    5. [NSNumber numberWithInteger:NSBeginsWithPredicateOperatorType],
    6. [NSNumber numberWithInteger:NSEndsWithPredicateOperatorType],
    7. [NSNumber numberWithInteger:NSContainsPredicateOperatorType],
    8. nil];
    9. NSPredicateEditorRowTemplate *template = [[NSPredicateEditorRowTemplate alloc] initWithLeftExpressions:keyPaths rightExpressionAttributeType:NSStringAttributeType modifier:NSDirectPredicateModifier operators:operators options:(NSCaseInsensitivePredicateOption | NSDiacriticInsensitivePredicateOption)];
    10. NSArray *compoundTypes = [NSArray arrayWithObjects:[NSNumber numberWithInteger:NSNotPredicateType], [NSNumber numberWithInteger:NSAndPredicateType], [NSNumber numberWithInteger:NSOrPredicateType], nil];
    11. NSPredicateEditorRowTemplate *compound = [[NSPredicateEditorRowTemplate alloc] initWithCompoundTypes:compoundTypes];
    12. NSArray *rowTemplates = [NSArray arrayWithObjects:template, compound, nil];
    13. [self.predicateEditor setRowTemplates:rowTemplates];
    Alles anzeigen


    Wenn der NSPredicateEditor nun sein Predicate bekommt, tritt obiger Fehler auf.

    Dabei sind die Templates doch vorhanden. Ein Check kurz vorher ergibt folgendes:

    Quellcode

    1. self.predicateEditor.rowTemplates: (
    2. "<NSPredicateEditorRowTemplate 0x107339310: [name, state] [4, 5, 8, 9, 99] NSStringAttributeType>",
    3. "<NSPredicateEditorRowTemplate 0x10733b130: compoundtypes [0, 1, 2]>"
    4. )


    Alles korrekt meiner Meinung nach.

    Weiß jemand weiter?

    Danke
    Daniel
    “I want to see an elephant hunt down a man for the sole purpose of collecting his teeth, while a chorus of typewriters sings songs that praises the bananas for their wisdom, leadership, and their high levels of potassium.” ― Jarod Kintz, I Want

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Daniel2 ()

  • Okay, wenn ich für jeden keyPath ein neues NSPredicateEditorRowTemplate erstelle funktioniert es. :)

    Des Weiteren brauchte ich für das "value"-Binding einen ValueTransformer. Ein einfacher String (der ja in meinem Fall mittels CoreData gespeichert werden soll) reicht nicht. Es muss ein ordentliches NSPredicate sein:

    Quellcode

    1. #import "StringToPredicateTransformer.h"
    2. @implementation StringToPredicateTransformer
    3. + (Class)transformedValueClass { return [NSPredicate class]; }
    4. + (BOOL)allowsReverseTransformation { return YES; }
    5. - (id)transformedValue:(id)value {
    6. return [NSPredicate predicateWithFormat:value];
    7. }
    8. - (id)reverseTransformedValue:(id)value
    9. {
    10. return [value description];
    11. }
    12. @end
    Alles anzeigen
    “I want to see an elephant hunt down a man for the sole purpose of collecting his teeth, while a chorus of typewriters sings songs that praises the bananas for their wisdom, leadership, and their high levels of potassium.” ― Jarod Kintz, I Want