How to get value from inside closure to set to a local variable
I have been trying fetch data from firebase and storing it in a dataModel using completion handler like this static var dataModels = [DataModel]() static func fetchData(completion: @escaping () -> Void) { let ref = Database.database().reference().child("data") ref.observe( .value, with: { snapshot in guard let value = snapshot.value as? [[String: Any]] else { return } for… Read More How to get value from inside closure to set to a local variable