我只想打印兒童計數並將其設置爲標籤。uint不可轉換爲int
這是我的JSON結構:
simplelogin2
- 名
- 年齡
- 後
- POST1: 「asdasd」
- p OST2: 「sadasd」
- post3: 「asdasd」
我想打印兒童的數量在後期或將其設置爲一個標籤,我應該怎麼辦呢?
我嘗試這樣做:
ref.childByAppendingPath("users").childByAppendingPath(ref.authData.uid).childByAppendingPath("post").observeSingleEventOfType(.Value, withBlock: { snapshot in
self.postCount = snapshot.childrenCount.value
println(self.postCount)
})'
,但它說字是不可轉換爲uint。
UPDATE:
這是我創建的用戶:
var userId = authData.uid
let newUser = [
"Provider" : authData.provider,
"email" : authData.providerData["email"] as? NSString as? String,
"name" : self.Name.text,
"Image" : "",
"location" : "",
"about" : "",
"age" : "",
]
self.ref.childByAppendingPath("users").childByAppendingPath(authData.uid).setValue(newUser)
這是我添加的子 「後」 到每一個用戶!
(一個按鈕內我沒有這種編碼)
ref.childByAppendingPath("users/\(ref.authData.uid)/post").childByAutoId().setValue(text.text)
我是這樣做的bcoz我想打印登錄用戶的帖子的兒童數量! –
問題不明確 – Mousavian
發佈更多代碼或顯示錯誤 – iAnurag