0
我一直盯着這幾個小時,無法弄清楚我做錯了什麼。下面的代碼保存創建一個新的「書」的對象,但BOOKNAME是空白......swift - uilalertcontroller textfield value returns empty
這裏是我的代碼:
var alert = UIAlertController(title: "New Book", message: "What is the name of this Book?", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
alert.addTextFieldWithConfigurationHandler { (textField) in
textField.placeholder = "New Book Name"
self.currentShelf.addNewBook(Book(bookName: textField.text))
}
self.presentViewController(alert, animated: true, completion: nil)
感謝您的幫助