0

In my example I saved complex data on Firebase and I want get it back.

When I am using this code I can get any values stoared in hashmap.

for rest in snapshot.children.allObjects as! [DataSnapshot] {

                guard let restDict = rest.value as? [String: Any] else { continue }
                let title = restDict["title"] as? String
                let genre = restDict["genre"] as? NSDictionary
                let singer = restDict["singer"] as? NSArray

                print(genre?["title"])

            }

in my database I also I have Singer as array (id, name, age).

How could I return this values as well?

2
  • What do you mean by an 'array'? Firebase doesn't allow for the storage of native arrays. Commented Jun 20, 2017 at 23:55
  • Please share the code of how you saved the data to Firebase. And a snippet of the JSON from your database (as text, no screenshot). You can get this by clicking the "Export JSON" link in your Firebase Database console. Commented Jun 21, 2017 at 2:20

1 Answer 1

1

I do not believe firebase can store array types, however Firebase does explain how to store a list of values in its documentation: https://firebase.googleblog.com/2014/04/best-practices-arrays-in-firebase.html Hope this was helpful :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.