Check if a string exists in an array case insensitively

前端 未结 11 1519
情歌与酒
情歌与酒 2020-12-09 07:45

Declaration:

let listArray = [\"kashif\"]
let word = \"kashif\"

then this

contains(listArray, word) 

Ret

11条回答
  •  爱一瞬间的悲伤
    2020-12-09 08:04

    For checking if a string exists in a array (case insensitively), please use

    listArray.localizedCaseInsensitiveContainsString(word) 
    

    where listArray is the name of array and word is your searched text

    This code works in Swift 2.2

提交回复
热议问题