Home:ALL Converter>Display Firestore data into UIPicker Swift 4

Display Firestore data into UIPicker Swift 4

Ask Time:2018-04-26T16:48:32         Author:madhatter989

Json Formatter

I am still new in swift development, my problem is, I have Firestore structure as below:

enter image description here

the problem is to display the list of title from firestore into a uipicker, I need to get data into an array like below: [firsProgramme, secondProgramme, thirdProgramme]

I managed to display all the "title" from firestore in the string, not in the array

below is the code:

func getprogram() {
 let db = Firestore.firestore()
    db.collection("Programme").getDocuments()
        {
            (querySnapshot, err) in

            if let err = err
            {
                print("Error getting documents: \(err)");
            }
            else
            {
                for document in querySnapshot!.documents {
                    let data = document.data()

                    let program = data["title"] as? String ?? ""
                  //  let agencyId = document.documentID
                    print(program)
                    //print("\(document.documentID) => \(document.data())");
                }

            }
    }

} 

result print(program) return as below :

firstprogramme

secondprogramme

thirdprogramme

the other part for UIPicker is already being managed well. Thanks in advance.

Author:madhatter989,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50038681/display-firestore-data-into-uipicker-swift-4
yy