You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I use the sample code it crashes with "Terminating app due to uncaught exception 'InvalidFirebaseData', reason: '(nodeFrom:priority:) Cannot store object of type _SwiftValue at . Can only store objects of type NSNumber, NSString, NSDictionary, and NSArray."
struct Test: Encodable {
var integer = Int(10)
var string = String("test")
}
func writeToFirebase(uid: String, completion: ( (Error?, DatabaseReference?)->() )? = nil ) {
do {
let data = try toFirebaseData() as [AnyHashable: Any]
log.debug("\(data)")
var t = Test()
firebaseRef(uid: uid).setValue(try FirebaseEncoder().encode(t)) {
(error, reference) in
completion?(error, reference)
}
} catch let error {
completion?(error, nil)
}
}
I believe the usage of setValue is wrong, if I change it to updateChildValues is works perfectly.
However, issue is that updateChildeValues will not replace the whole data under the key which I need (and that is why I wanted to use setValue).
The text was updated successfully, but these errors were encountered:
FirestoreManager.shared.db.collection("data").getDocuments { documents, error in
if let documents = documents {
for document in documents.documents {
guard let model = try? FirestoreDecoder().decode(Model.self, from: document.data()) else { print("Error"); return }
print("Model: \(model.name), \(model.email), \(model.location), \(model.details.dealbreakers)")
}
} else {
print("Document does not exist")
}
}
If I use the sample code it crashes with "Terminating app due to uncaught exception 'InvalidFirebaseData', reason: '(nodeFrom:priority:) Cannot store object of type _SwiftValue at . Can only store objects of type NSNumber, NSString, NSDictionary, and NSArray."
I believe the usage of setValue is wrong, if I change it to updateChildValues is works perfectly.
However, issue is that updateChildeValues will not replace the whole data under the key which I need (and that is why I wanted to use setValue).
The text was updated successfully, but these errors were encountered: