【发布时间】:2021-01-03 09:41:19
【问题描述】:
下面的函数总是返回 false。我试图将return 放在它也不接受的完成中。
你能帮帮我吗?
// MARK: - make Alert for user Input
func makeAlert(message: String, defaultButtonText: String, cancelButtonText: String) - > Bool {
var answer = Bool()
let alert = UIAlertController(title: "Warning", message: message, preferredStyle: .alert)
let actionYes = UIAlertAction(title: defaultButtonText, style: .default) {
(action) in
answer = true
}
let actionNo = UIAlertAction(title: cancelButtonText, style: .default) {
(action) in
answer = false
}
alert.addAction(actionNo)
alert.addAction(actionYes)
self.present(alert, animated: true, completion: {
print(answer)
})
return answer
}
【问题讨论】:
标签: swift alert uialertview swift5