I've got a problem with 'Declaration is only valid at file scope' error I was not modifying any other files than mainstoryboard. Those are all places. (whiteout one 'If != nil') where I was using TextFields. I've been trying nearly everything. Thanks for any help
Code:
class ViewController: UIViewController {
//inputs
@IBOutlet weak var creditValueInput: UITextField! //wartość kredytu, input
@IBOutlet weak var procentageInput: UITextField! //oprocentowanie, input
@IBOutlet weak var yearsInput: UITextField! //ile lat/miesiecy, input
@IBOutlet weak var creditOverallOutput: UILabel!
@IBOutlet weak var creditCalculationOutput: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
self.creditValueInput.delegate = (self as! UITextFieldDelegate)
self.procentageInput.delegate = (self as! UITextFieldDelegate)
self.yearsInput.delegate = (self as! UITextFieldDelegate)
// Do any additional setup after loading the view.
}
......
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
creditValueInput.resignFirstResponder()
procentageInput.resignFirstResponder()
yearsInput.resignFirstResponder()
.....
extension ViewController: UITextFieldDelegate { !Declaration is only valid at file scope!
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
}
}
Thanks for any help