I wanted to create a morse code translator app on xcode. The translation for English to Morse works fine, but this reverse process does not. Whats wrong with my code?
let input = inputTextField.text!
var output = ""
var Dict = [".-" : "a", "-..." : "b"]
for character in input.characters {
let characters = "\(character)"
if let translatedcharacters = Dict[characters] {
output += translatedcharacters
} else {
output += characters
}
}
outputLabel.text = output
the output shown is not "a" or "b" but just the input which is either ".-" or "-..."