I am having some trouble with the return key on the keyboard executing code. I have tried in the past and the following code worked perfectly fine:
func textFieldShouldReturn(textField: UITextField) -> Bool{
textField.resignFirstResponder()
valueOfLetter()
return true;
}
But, for some reason, there is an error on the line valueOfLetter
.
Here is the entire file in case it is necessary:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBOutlet weak var strWordValue: UILabel!
@IBOutlet weak var strInputField: UITextField!
func textFieldShouldReturn(textField: UITextField) -> Bool{
textField.resignFirstResponder()
valueOfLetter()
return true;
}
var TextField: UITextField!
func valueOfLetter(inputLetter: String) -> Int {
let alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
for (index, letter) in alphabet {
if letter = inputLetter.lowercaseString {
return index + 1
for character in word {
score += valueOfLetter(character)
}
}
}
return 0
}
}
The error is: "missing argument in parameter #1 in call
The is another error on the line for (index, letter) in alphabet
which says: 'String' not convertible to '([String, String])'
I am unsure of what these errors mean or how to fix them.
Any input or suggestions would be greatly appreciated.
Thanks in advance.