开发者

NSPredicateEditor query not working

开发者 https://www.devze.com 2023-01-25 13:17 出处:网络
I\'ve got a Problem with my NSPredicateEditor. I want to use it for filtering a array of dictionarys.

I've got a Problem with my NSPredicateEditor. I want to use it for filtering a array of dictionarys.

NSArray events = {(Stadt=>Berlin), (Stadt=>Munich), nil }

The following code is working:

开发者_如何学Python    predicate = [NSPredicate predicateWithFormat:@"Stadt LIKE %@", @"Berlin"];
    NSLog(@"%@", predicate);
    events = [events filteredArrayUsingPredicate:predicate];

The NSLog result is: Stadt LIKE "Berlin"

If I get the predicate from NSPredicateEditor I get the same NSLog result but the result array (events) is empty !

Code:

    predicate = [predicateEditor predicate];
    XLog(@"%@", predicate);
    events = [events filteredArrayUsingPredicate:predicate];

Thanks, Andreas


NSPredicateEditor does not have a -predicate method. It has an objectValue method, and you should use that instead. Perhaps you could provide more information, such as what is getting logged in the second block?

0

精彩评论

暂无评论...
验证码 换一张
取 消