Reputation: 153
I have an array like this: var myArray = [(String, Int)]()
I would like to write this to Firebase, but get the error: "Can only store objects of type NSNumber, NSString, NSDictionary, and NSArray"
When I do this: ("\(myArray)")
when updating childValues, it goes through, but it also writes all the ""´s, ()´s and \´s
I have a webpage that reads from Firebase, and I would like to make it look nicer by removing the extra characters.
Is it possible to convert my array or something to make Firebase accept it?
Upvotes: 0
Views: 390
Reputation: 285079
Your array is an array of tuples and a tuple is not one of the supported types.
You could map the tuple to a real array
let realArray = myArray.map{[$0.0, $0.1]}
Please consider this note from the documentation:
Tuples are useful for temporary groups of related values. They’re not suited to the creation of complex data structures. If your data structure is likely to persist beyond a temporary scope, model it as a class or structure, rather than as a tuple.
Upvotes: 1