0

I'm trying to access department and course information for an iOS app for students to buy/sell textbooks.

Right now I have two pickerViews. I'd like to select the department in one and have the relevant courses load into the second. What kind of call can I make to get an array of just the department names when structured as below?

firebase data example

So here I would want to access an array ["AHSS", "AIE", "ANTH"]. Then afterwards, I'd make another call depending on the selection. For AIE, I'd want the array ["330", "340"].

I'm unsure how I can just get the directory names as an array and not the values they eventually lead to?

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
tim_d
  • 133
  • 2
  • 11

1 Answers1

0

For anyone else that might have had this question. @Nikunj Kumbhani directed me in the right direction and I eventually got this which lists the key values.

myDatabase.child("departments").child("\(selectedDepartment ?? "AHSS")").observeSingleEvent(of: .value) { (snapshot) in

            if let myData = snapshot.value as? NSDictionary {

                for name in myData.keyEnumerator() {
                    stringList.append("\(name)")
                }
tim_d
  • 133
  • 2
  • 11