I've got an func that read data from DB. this func with @escaping. how should I declare a var in UI, to get my result. thanks
class GetGarbageInfo {
func getInfo(path: String, completion: @escaping (String) -> Void) {
var result = ""
let rootReference = Database.database().reference()
let garbageReference = rootReference.child("GarbageInformation").child(path).child("body")
garbageReference.observeSingleEvent(of: .value) { (DataSnapshot) in
result = DataSnapshot.value as? String ?? "0"
}
completion(result)
}
}