Try the following:
var a = "Cash" var b = "cash" let result: NSComparisonResult = a.compare(b, options: NSStringCompareOptions.CaseInsensitiveSearch, range: nil, locale: nil)
result - enumeration type NSComparisonResult:
enum NSComparisonResult : Int { case OrderedAscending case OrderedSame case OrderedDescending }
So you can use the if statement:
if result == .OrderedSame { println("equal") } else { println("not equal") }
Greg May 29 '15 at 14:57 2015-05-29 14:57
source share