How to perform reversing of all words in a sentence.
Example
let str = \"Hello playground\"
Result should be like \"olleH dnuorg
Building on the OPs answer, if you wanted to follow English capitalization rules on the output:
var str = "Hello playground"
let result = str.split(separator: " ").enumerated().map {
let reversed = String($0.1.reversed())
return $0.0 == 0 ? reversed.capitalized : reversed.lowercased()
}
.joined(separator: " ")
print("Rerversing letters in each word = \"" + result + "\"") // Olleh dnuorgyalp
Also note that multiple spaces would mess this up, as would commas, periods, and other word/sentence delimiters.