【发布时间】:2018-09-20 08:01:02
【问题描述】:
value:Optional({
"-LMpUBhCddHrShVWPVAx" = {
mobile = "(555) 564-8583";
name = "Kate Bell";
};
"-LMpUBhD9-sX8p2Y3EuB" = {
mobile = "(408) 555-5270";
name = "Daniel Higgins Jr.";
};
"-LMpUBhD9-sX8p2Y3EuC" = {
mobile = "888-555-5512";
name = "John Appleseed";
};
})
我有这组从 Firebase 获得的字典数据。但是如何将其保存到数组中?我想要的数据是手机和姓名。
这是我的代码:
func retrieveLists() {
ref = Database.database().reference()
ref.child("users").child("60123456789").child("contact_lists").observeSingleEvent(of: .value, with: { (snapshot) in
let value = snapshot.value as? NSDictionary
print("value:\(value)")
}) { (error) in
print(error.localizedDescription)
}
}
【问题讨论】:
-
那么你在 print("value:(value)") 行中得到了什么日志
标签: swift firebase dictionary firebase-realtime-database