0
我做的一個項目,該項目是關心火力地堡,我試圖將數據上傳到火力地堡從火力地堡網站的教程中的代碼:爲什麼我無法以這種方式將數據添加到Firebase中?
// An index to track Ada's memberships
{
"users": {
"alovelace": {
"name": "Ada Lovelace",
// Index Ada's groups in her profile
"groups": {
// the value here doesn't matter, just that the key exists
"techpioneers": true,
"womentechmakers": true
}
},
...
},
"groups": {
"techpioneers": {
"name": "Historical Tech Pioneers",
"members": {
"alovelace": true,
"ghopper": true,
"eclarke": true
}
},
...
}
}
,我按照這個結構來寫我自己數據結構,它看起來像這樣:
func pushUser() {
let username = self.username
let userid = FIRAuth.auth()?.currentUser?.uid
let userInfo : [String : Any] = ["username" : username,
"userID" : userid,
"sggestedRoutes" : "",
"myTracedRoutes" : "",
"routes": {
"usualInfo" : true,
"calcuInfo" : true
}
]
let userRef = FIRDatabase.database().reference()
userRef.child("user").childByAutoId().setValue(userInfo)
}
在Swift3
,但調試說嵌套路線{}是不正確的,我很困惑這一點,任何人都可以給我這樣的暗示?
親切的問候
收到的意見後,我就在代碼的一些變化,但現在還沒有在路由部分工作:(
func pushUser() {
let username = self.username
let userid = FIRAuth.auth()?.currentUser?.uid
let userInfo : [String : Any] =
["username" : username,
"userID" : userid,
"sggestedRoutes" : "",
"uploadedRoutes" : "",
"myTracedRoutes" : "",
["Routes":
["usualInfo" : true,
"calcuInfo" : true]
]
]
let userRef = FIRDatabase.database().reference()
userRef.child("user").childByAutoId().setValue(userInfo)
}
你好,謝謝你的回覆,但是這個也不行,xCode會通知你在間隔裏應該有個「:」,我還不知道還有:( – Jenny