Hello all, I'm trying to display the result in a UITextField, but I'm getting the following error: Cannot convert value of type 'String?' to expected argument type '[Int]'
I'm also new to swift, and I understand little bit about the issue, but unfortunatelly not enough to fix it. So, your help will be much appreciated.
This is the code:
@IBAction func decrypt(sender: AnyObject?) {
func decrypt(text: String, key:[Int]) -> String {
let text = text.lowercased()
let map = self.map()
var output = String()
for (index, character) in text.characters.enumerated() {
if character == " " {
output.append(character)
} else {
if let letterIndex = map.forward[String(character)] {
let keyIndex = key[index]
let outputIndex = (letterIndex - keyIndex + map.lastCharacterIndex) % map.lastCharacterIndex
if let outputCharacter = map.reversed[outputIndex] {
output.append(outputCharacter)
}
}
}
}
return output
}
let text = decryptText.text
let key = pskey.text
/
let (resultText, resultKey) = decrypt(text: text!, key: key)
/
outputText.text = resultText
}Line 31 is where I get the error.