Accent insensitive string comparison?

后端 未结 2 1413
渐次进展
渐次进展 2020-12-20 12:12

Is there any way to do an accent insensitive string comparison? For example, é == e? I couldn\'t find any options to pass rangeOfString:options:. Any help is greatly appreci

2条回答
  •  抹茶落季
    2020-12-20 12:23

    If you also want a substring search and have an array of items you want to filter I recommend this:

    [self.objects filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id  _Nullable evaluatedObject, NSDictionary * _Nullable bindings) {
        MyClass *object = (MyClass *)evaluatedObject;
        if ([object.name localizedStandardContainsString:filterString]) return YES;
        return NO;
    }]];
    

提交回复
热议问题