firebase/snippets-ios

Value of type 'NSObject' has no member 'data' -- custom objects

AFRUITPIE opened this issue · 1 comments

let docRef = db.collection("cities").document("BJ")
docRef.getDocument { (document, error) in
let result = Result {
try document.flatMap {
try $0.data(as: City.self)
}
}
switch result {
case .success(let city):
if let city = city {
print("City: \(city)")
} else {
print("Document does not exist")
}
case .failure(let error):
print("Error decoding city: \(error)")
}
}

System information (OS, Device, etc): macOS 10.15.3, Xcode 11.3.1

What steps will reproduce the problem:

  1. Use the snippet in a Firestore project

What is the expected result?
The snippet will cast the Firestore document to the given type

What happens instead of that?
Error: "Value of type 'NSObject' has no member 'data'

Code, logs, or screenshot that illustrate the problem:
Screen Shot 2020-03-12 at 10 22 37 PM