Just My Life & My Work

Posts tagged ‘predicate’

[iOS] 謂詞不區分大小寫 (Predicate for Case-Insensitive)

處理字串真的是一門大學問,這次我想要搜尋某個關鍵字,是英文且不區分大小寫,此時我可以怎麼做?

我們可以使用Predicate設定Case-Insensitive,翻譯成中文是謂詞不區分大小寫,真是彆扭啊~

Apple官方文件有段描述:

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中加入[cd],就能找到英文不區分大小寫的字串囉~

(繼續閱讀…)

標籤雲

%d 位部落客按了讚: