Home>

I want to get information on iPhone using Firebase.
The information of the collection itself can be acquired from one document of Firebase, but I want to acquire the specification of the document from which information is acquired with TextField etc. I think that a variable is necessary to specify a document from TextField etc. How can I add a variable to the document specification location? Reading the official document did not help. I think it is fundamental, but I would appreciate it if you could tell me.

Applicable source code
@ IBAction func load () {
        let db = Firestore.firestore ()
        db.collection ("recipe"). document ("176")
            .addSnapshotListener {documentSnapshot, error in
                guard let document = documentSnapshot else {
                    print ("Error fetching document: \ (error!)")
                    return
                }
                guard let data = document.data () else {
                    print ("Document data was empty.")
                    return
                }
                self.name.text = document ["name"] as! String
                self.url.text = document ["url"] as! String
        }
    }

db.collection ("recipe"). document ("176")
("176") of the document is specified, so I tried to make it a simple variable, textfield.text etc. of the text field.

Supplemental information (FW/tool version etc.)

Xcode
Firebase
FireStore