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 true if we compare var a & var b
Try this :
For older swift:
var a : String = "Cash" var b : String = "cash" if(a.caseInsensitiveCompare(b) == NSComparisonResult.OrderedSame){ println("Et voila") }
Swift 3+
var a : String = "Cash" var b : String = "cash" if(a.caseInsensitiveCompare(b) == .orderedSame){ print("Et voila") }
2.1m questions
2.1m answers
60 comments
57.0k users