Make powerHp optional

This commit is contained in:
Selim Mustafaev 2023-05-16 22:18:11 +03:00
parent 1cfa6bb29f
commit 4c2811246d
2 changed files with 3 additions and 3 deletions

View File

@ -26,7 +26,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let config = Realm.Configuration(
schemaVersion: 39,
schemaVersion: 40,
migrationBlock: { migration, oldSchemaVersion in
if oldSchemaVersion <= 31 {
migration.enumerateObjects(ofType: "Vehicle") { old, new in

View File

@ -43,7 +43,7 @@ public class VehicleModel: Object, Decodable, Cloneable {
public class VehicleEngine: Object, Decodable, Cloneable {
@Persisted public var number: String?
@Persisted public var volume: Int? = 0
@Persisted public var powerHp: Float = 0
@Persisted public var powerHp: Float? = 0
@Persisted public var powerKw: Float? = 0
@Persisted public var fuelType: String?
@ -55,7 +55,7 @@ public class VehicleEngine: Object, Decodable, Cloneable {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.number = try container.decodeIfPresent(String.self, forKey: .number)
self.volume = try container.decodeIfPresent(Int.self, forKey: .volume)
self.powerHp = try container.decode(Float.self, forKey: .powerHp)
self.powerHp = try container.decodeIfPresent(Float.self, forKey: .powerHp)
self.powerKw = try container.decodeIfPresent(Float.self, forKey: .powerKw)
self.fuelType = try container.decodeIfPresent(String.self, forKey: .fuelType)
}