我试图在键中循环并获取值,这是我的代码,并卡在这里
func fetchData(){
ref = Database.database().reference()
let userid = Auth.auth().currentUser?.uid
HUD.show(.progress)
ref.child("start_shift").child(userid!).observeSingleEvent(of: .value) { (snapshot) in
print(snapshot)
let listOfShifts = snapshot.value as? [String:Any] ?? [:]
for key in listOfShifts.keys{
print(key)
self.arrShiftKeys.append(key)
self.ref.child(userid!).child(key).observeSingleEvent(of: .value, with: { (snap) in
let dictionary = snap.value as? [String:Any] ?? [:]
let assignmentType = dictionary["assignment_type"] as? String ?? ""
print(assignmentType)
let date = dictionary["date"] as? String ?? ""
print(date)
})
}
}
HUD.hide()
self.tableVieww.reloadData()
}