我試圖獲取值居住使用此功能:斯威夫特IOS火力地堡不返回任何數據
handle = ref?.child("Users").child(String(itemId)).observe(.childChanged, with: { (snapShot) in
if let dictionary = snapShot.value as? [String: Any] {
print(dictionary)
if let profileImageUrl = dictionary["url"] as? String {
print(profileImageUrl)
}
}
}, withCancel: nil)
我開始我的應用程序,然後我去我的火力控制檯和做一些改變這個孩子,但我print()
從未被解僱。
這是我的數據庫看起來像:
MyRootDb123
-Users
--Id (Child of users)
--- url inside Id
--- name inside Id
--- age inside Id
而且在我的代碼,什麼是withCancel
功能嗎?
更新 我加print(snapShot)
返回:
Snap (url) www.someurl.com
哪一個不會觸發'print(dictionary)'? –
@NazmulHasan沒有人被解僱,如果讓字典= snapShot.value爲? [String:Any] {''我認爲我不能使用[String:Any] – Kiow
@NazmulHasan我添加了'print(snapShot)',它返回: Snap(url)www.someurl.com – Kiow