How to compare two strings ignoring case in Swift language?

后端 未结 16 2619
孤街浪徒
孤街浪徒 2020-12-13 05:28

How can we compare two strings in swift ignoring case ? for eg :

var a = \"Cash\"
var b = \"cash\"

Is there any method that will return tru

16条回答
  •  无人及你
    2020-12-13 05:47

    Phone numbers comparison example; using swift 4.2

    var selectPhone = [String]()
    
    if selectPhone.index(where: {$0.caseInsensitiveCompare(contactsList[indexPath.row].phone!) == .orderedSame}) != nil {
        print("Same value")
    } else {
        print("Not the same")
    }
    

提交回复
热议问题