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") }
1.4m articles
1.4m replys
5 comments
57.0k users