2017-02-04 176 views
-1

我對編程相當陌生。我正在嘗試創建一個應用程序,並在網上找到了一些很棒的教程,但沒有一個能夠告訴我需要什麼。我希望能夠使用幾個文本字段在我的Firebase數據庫中創建一些如下所示的內容。 This is what I want my database to look like.Firebase兒童讀/寫

任何幫助將不勝感激。提前致謝!

編輯

這是我不得不盡可能去代碼。我不在乎它是否是childByAutoId,但我希望自動ID的設置值是配方的標題。

let newRecipe = ref?.childByAutoId() 
     newRecipe?.child("Title").setValue(titleTextView.text) 
     newRecipe?.child("Ingredients").setValue(ingredientsTextView.text) 
     newRecipe?.child("Instructions").setValue(instructionsTextView.text) 

回答

0

調用childByAutoId生成(顧名思義)與自動生成的ID(通常稱爲火力地堡的背景下,推動ID)一個孩子。

如果要指定自己的孩子在代碼中的關鍵,使用FIRDatabaseReferece.child

let newRecipe = ref?.child("Recipe 1")