I am having problems with the return key on a keyboard executing code. I tried in the past and the following code worked perfectly:
func textFieldShouldReturn(textField: UITextField) -> Bool{
textField.resignFirstResponder()
valueOfLetter()
return true;
}
But for some reason valueOfLetterthere is an error on the line .
Here is the whole file if 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
}
}
Error: "Missing argument in parameter No. 1 when called
Another error in a string for (index, letter) in alphabetthat states: 'String' does not convert to '([String, String])'
I'm not sure what these errors mean or how to fix them.
Any materials or suggestions are welcome.
Thanks in advance.