Похоже, вы запутались в скобках.Вы закрыли IBAction func
после настройки action
.
Обновленный код:
@IBAction func addButtonPressed(_ sender: UIBarButtonItem) {
var textField = UITextField()
let alert = UIAlertController(title: "Add New File", message:"", preferredStyle: .alert)
let action = UIAlertAction(title: "Add Item", style: .default) { (action) in
//what will happen after user clicks button
print(textField.text)
}
alert.addTextField { (alertTextField) in //where the error begins help
alertTextField.placeholder = "Create New File"
textField = alertTextField
}
present(alert,animated: true,completion:nil)
}