case insensitive matching search in string array swift 3

前端 未结 4 459
余生分开走
余生分开走 2021-01-07 17:21

In Swift 3, I want to create an array of matching string (case insensitive) from string array:-

I am using this code, but it is case sensitive,

let          


        
4条回答
  •  抹茶落季
    2021-01-07 17:49

    The easiest way might be to lowercase your strings and compare:

    Swift 3 and above

    let filteredArray = self.arrCountry.filter { $0.lowercased() == "india" }
    

提交回复
热议问题