I am using this class to create an object but when I archive and unarchive from and to UserDefaults it only gives me the value of trialUrl but not it's superclass properties.Since I don't know if CLCircularRegion supports Codable protocol I'm stuck with this approach.
class TrialRegion: CLCircularRegion{
var trailUrl:URL?
init(center: CLLocationCoordinate2D, radius: CLLocationDistance, identifier: String,trailUrl:URL) {
super.init(center: center, radius: radius, identifier: identifier)
self.trailUrl = trailUrl
}
override func encode(with aCoder: NSCoder) {
super.encode(with: aCoder)
aCoder.encode(URL.self, forKey: "trialUrl")
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
guard let url = aDecoder.decodeObject(of: NSURL.self, forKey: "trialUrl") as URL? else {return}
self.trailUrl = url
}
}