I'm new to Swift object oriented dev in general. I'm trying to load the query results from Firebase into a ViewController. I'm struggling with get the QuerySnapShot into an object to be used as the source for the View Controller. Specifically, I keep getting a "Unexpected non-void return value in void function" error where the return statement is. Any ideas? It there's a better way to do this in general please let me know. Any help is much appreciated.
// MARK: - API
func getBoxContents() -> Dictionary<String, Any> {
// Get user data to populate collection view
let userRef = db.collection("documents")
var userData: Array<Dictionary<String,Any>> = []
userRef.whereField("email", isEqualTo: userEmail!).getDocuments() { (querySnapshot, err) in
if let err = err {
print("Error getting documents: \(err)")
} else {
for document in querySnapshot!.documents {
var userData = document.data()
print("\(document.documentID) => \(document.data())")
}
return userData
}
}
}