I addition to @JJSaccolo
answer, you can create custom equals
method as new String extension like:
extension String {
func isEqualToString(find: String) -> Bool {
return String(format: self) == find
}
}
And usage:
let a = "abc"
let b = "abc"
if a.isEqualToString(b) {
println("Equals")
}
For sure original operator ==
might be better (works like in Javascript) but for me isEqual
method gives some code clearness that we compare Strings
Hope it will help to someone,