0
由於某些原因,我的文本字段在我的Firebase數據庫中爲空...我沒有得到我的用戶輸入。使用火力的第一天,我可能會錯過一些簡單..testfields用戶輸入未進入Firebase數據庫
var tickets = [Ticket]()
func test() {
let ref = FIRDatabase.database().reference().child("tickets")
let childRef = ref.childByAutoId()
guard let Price = emailTextField.text, ticketName = passwordTextField.text else {
print("Form is not valid")
return
}
let values: [String: AnyObject] = ["Price": Price, "ticketName": ticketName]
ref.observeEventType(.ChildAdded, withBlock: { (snapshot) in
let ticketId = snapshot.key
let ticksRef = FIRDatabase.database().reference().child("tickets").child(ticketId)
ticksRef.observeSingleEventOfType(.Value, withBlock: { (snapshot) in
guard let dictionary = snapshot.value as? [String: AnyObject] else {
return
}
self.messages.append(Ticket(dictionary: dictionary))
childRef.updateChildValues(values) { (error, ref) in
if error != nil {
print(error)
return
}
}
你是什麼意思:*我的textfields在我的firebase數據庫中是空的* – Dravidian
我的意思是在firebase中我看不到用戶從textfields輸入的內容是......他們只是有「」而沒有別的 – Frederic
試試打印那些文本框就在你保存到FBDB之前,你會得到零嗎? – Dravidian