NSPredicate case-insensitive matching on to-many relationship

后端 未结 5 1554
攒了一身酷
攒了一身酷 2020-12-07 09:48

I am implementing a search field where the user can type in a string to filter the items displayed in a view. Each object being displayed has a keywords to-man

5条回答
  •  春和景丽
    2020-12-07 10:38

    I believe the answer is:

    [NSPredicate predicateWithFormat:@"keywords.name CONTAINS[cd] %@", self.searchString];
    

    String comparisons are by default case and diacritic sensitive. You can modify an operator using the key characters c and d within square braces to specify case and diacritic insensitivity respectively, for example firstName BEGINSWITH[cd] $FIRST_NAME.

    Predicate Format String Syntax

提交回复
热议问题