简体   繁体   中英

How can I make Firestore's GeoPoint conform to Swifts Codable protocol?

I am trying to make the response from firestore queries conform to swift 4 codable protocol. But I am having trouble making GeoPoint conform to Codable as the class is already declared in the Firestore library. Thank you for your help.

ie

struct Landmark:Codable {
let name:String
let location:GeoPoint 
}

Did you try with an extension?

extension GeoPoint: Codable {
// custom codable implementation
}

Basically, the extension allows you to add functions, computed property and protocol conformance to an existing class/struct

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM