Laurent 7 months ago
commit 51163af3a3
  1. 13
      LeStorage/Codables/Settings.swift

@ -18,4 +18,17 @@ class Settings: MicroStorable {
var deviceId: String? = nil var deviceId: String? = nil
var lastSynchronization: String = "2000-01-01T00:00:00.000000Z" var lastSynchronization: String = "2000-01-01T00:00:00.000000Z"
// WARNING: adding mandatory variable is not without consequences !!!
// Please add to the decoder below
required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
userId = try container.decodeIfPresent(String.self, forKey: .userId)
username = try container.decodeIfPresent(String.self, forKey: .username)
deviceId = try container.decodeIfPresent(String.self, forKey: .deviceId)
lastSynchronization = try container.decodeIfPresent(String.self, forKey: .lastSynchronization) ?? "2000-01-01T00:00:00.000000Z"
}
} }

Loading…
Cancel
Save