i'm creating my first app (and newbie in swift). When i login from Facebook, the name and email are saved in Firestore. I'm trying to set the name from facebook to a variable to use it in other places, but i can't assign the value, always shows "nil" in the console. Anyone can help me please?
- I set the variable
var userN: String?
- I get the data from Firestore
func readDatabase(){
    let db = Firestore.firestore()
    let docRef = db.collection("users").document("email")
    docRef.getDocument { (document, error) in
        if let document = document, document.exists {
            let dataDescription = document.data().map(String.init(describing:)) ?? "nil"
            print("Document data: \(dataDescription)")
            let data = document.data()
            let userName = data!["name"]! as! String
            print(userName)
            let userEmail = data!["email"]! as! String
            print(userEmail)
let containerController = ContainerController()
            let containerController.userN = userName;
            return
        }
    }
}
i want to assign userN = userName, to use it in other view
How can i do that? thanks
 
     
     
    