I can’t get 3 values out of a function, I get an error message:
Cannot convert value of type ‘(String, String, String)’ to closure result type ‘Void’
this is the code:
func readDataUser() -> (uid: String, plan: String, role: String) {
let ref = Database.database().reference()
let userUid = AuthManager.shared.retrieveUid
let nodeUser = ref.child(RefDatabase.users.rawValue).child(userUid())
nodeUser.observeSingleEvent(of: .value) { snapshot in
let uid = snapshot.childSnapshot(forPath: "uid").value as? String ?? "no name"
let plan = snapshot.childSnapshot(forPath: "plan").value as? String ?? "no name"
let role = snapshot.childSnapshot(forPath: "role").value as? String ?? "no name"
return (uid, plan, role)
}
}
I would like you to print the values for me:
let dataUser = RealtimeManager.shared.readDataUser()
print("User data is: (dataUser.uid) - (dataUser.plan) - (dataUser.role)")