Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable decoding GeoPoint #74

Open
MartijnSchoemaker opened this issue Jul 7, 2019 · 0 comments
Open

Unable decoding GeoPoint #74

MartijnSchoemaker opened this issue Jul 7, 2019 · 0 comments

Comments

@MartijnSchoemaker
Copy link

MartijnSchoemaker commented Jul 7, 2019

I already found the other issue about this problem, but it's still not fixed for me. Probably I'm doing something very wrong, but I cannot find it.

At first I also used FirebaseDecoder, but switching to FirestoreDecoder doesnt solve the issue. The issue is this error:
Swift.DecodingError.typeMismatch(Swift.Dictionary<Swift.String, Any>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "location", intValue: nil)], debugDescription: "Not a dictionary", underlyingError: nil))

Code looks like this:

struct Restaurant: Decodable {
    var address: String
    var city: String
    var name: String
    var location: GeoPoint
}

extension GeoPoint: GeoPointType {}
let restaurant = try! FirestoreDecoder().decode(Restaurant.self, from: snapshot.data()!)

snapshot.data():

(lldb) po snapshot.data()
▿ Optional<Dictionary<String, Any>>
  ▿ some : 4 elements
    ▿ 0 : 2 elements
      - key : "location"
      - value : <FIRGeoPoint: (52.097472, 5.115436)>
    ▿ 1 : 2 elements
      - key : "address"
      - value : asdf
    ▿ 2 : 2 elements
      - key : "city"
      - value : asdfd
    ▿ 3 : 2 elements
      - key : "name"
      - value : asdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant