我试图获取值居住使用此功能:斯威夫特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