I have an array in Firebase composed of 1's and 0's (true and false basically), they are all stored as separate key/value pairs. I would like to retrieve them from Firebase and append each value to an array in Swift.
I have tried this (found elsewhere on SO) but it is not working.
let ref = Firebase(url:"https://<<unique>>.firebaseio.com/users/\(self.UUID)/scoreArray")
ref.observeSingleEventOfType(.Value, withBlock: { snapshot in
if snapshot.value is NSNull {
print("snap is null")
} else {
let enumerator = snapshot.children
while let rest = enumerator.nextObject() as? FDataSnapshot {
self.scoreArray.append(rest.value! as! String)
}
}
})
It doesn't crash, it just doesn't fill the array, even though if I print(rest.value)
it will give me the array.
So I guess the question is, how do I convert rest.value
into a usable form?
EDIT Firebase structure as requested.
66EC8AC4-<<rest of UUID>>
creation_date: "Jun 10, 2016"
extra_quiz_1
q1: "a"
q10: "b"
<<Continues>>
scoreArray
0: "0"
1: "1"
2: "0"
3: "0"
<<continues>>