0

I am trying to load an array of arrays with Firebase and would appreciate any help on how to do so. Thanks! Picture is of database.

enter image description here

1 Answer 1

1

You need to observe defense then inside the callback

self.ref.child("defense").observeSingleEvent(of: .value, with: { snap in 
   let res = snap.value as! [String:[String:Int]]
   let all = Array(res.values).map { Array($0.values) } // [[-1,-1,-1],[...]]
})
Sign up to request clarification or add additional context in comments.

6 Comments

its giving me 'Could not cast value of type '__NSArrayM' (0x1f4932630) to 'NSDictionary' (0x1f49335f8).'
tell me what this gives print(type(of:snap.value))
its a Optional<Any>
and this let res = snap.value as! [[String:Any]]
it says res is a ([[String: Any]]). The program stops and shows the varbiable values in the feed. No error msg just program breaks.
|

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.