Hello everyone!
A few months ago, I was coding a translation app that uses inputs from a textbox and translates that text into a different language. I have been using this code for quite some time now:
var code = [
"A" : "Example",
]
let message = Text.text
var encodedMessage = " "
let array = message!.characters.split(separator: " ")
for singleWord in array {
let word = String(singleWord)
if let encodedWord = code[word] {
encodedMessage += encodedWord
}
else {
encodedMessage += word
}
encodedMessage += " "
}
print(encodedMessage)
All of this worked fine in Swift 4. When I returned to this a few weeks ago and updated to Swift 5, I kept getting an error at this point in the code:
let array = message!.characters.split(separator: " ")
I know that the characters function has been removed and Swift has updated its functions in regards to strings, but I don't know enough about Swift 5 to be able to fix it. Is there a way to work around this issue without having to rewrite the entire code? (Also, apologies for the formatting, I am a bit new to this).