开发者

NSPredicate of special characters - iPhone

开发者 https://www.devze.com 2022-12-23 16:37 出处:网络
I\'m trying to make a predicate that includes special characters For example: [[myIngredients filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@\"name BEGINSWITH[c] %@\", [alphabet objectA

I'm trying to make a predicate that includes special characters

For example:

[[myIngredients filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"name BEGINSWITH[c] %@", [alphabet objectAtIndex:idx]]];

Here I will get all the ingredient which starts with (let say for idx = 5) 'e'. As I have to do my app 开发者_运维百科in english and french, some ingredients start with special character like 'é' or even 'œ' for 'o'. How can I include these special characters in my predicate?

Best


I think you might be looking for the “diacritic insensitive” flag that NSPredicate supports. It’s just like the “c” flag you’re already using, except you use a “d”. Like so:

… predicateWithFormat:@"name BEGINSWITH[cd] %@", …

Now the string “e” will also match “é”, “ê”, “ë”, and so on.

0

精彩评论

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

关注公众号