开发者

NSPredicate of special characters - iPhone

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜