I'm getting strings from a server that is all caps like:
"HELLO WORLD"
but I'm trying to make is so each word is caps on its own like:
"Hello World"
I've tried this:
extension String {
func capitalizingFirstLetter() -> String {
let first = String(characters.prefix(1)).capitalized
let other = String(characters.dropFirst()).lowercased()
return first + other
}
mutating func capitalizeFirstLetter() {
self = self.capitalizingFirstLetter()
}
}
but the result is
"Hello world"
any idea on how to do this?