Make powerHp optional
This commit is contained in:
parent
1cfa6bb29f
commit
4c2811246d
@ -26,7 +26,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
|
|
||||||
let config = Realm.Configuration(
|
let config = Realm.Configuration(
|
||||||
schemaVersion: 39,
|
schemaVersion: 40,
|
||||||
migrationBlock: { migration, oldSchemaVersion in
|
migrationBlock: { migration, oldSchemaVersion in
|
||||||
if oldSchemaVersion <= 31 {
|
if oldSchemaVersion <= 31 {
|
||||||
migration.enumerateObjects(ofType: "Vehicle") { old, new in
|
migration.enumerateObjects(ofType: "Vehicle") { old, new in
|
||||||
|
|||||||
@ -43,7 +43,7 @@ public class VehicleModel: Object, Decodable, Cloneable {
|
|||||||
public class VehicleEngine: Object, Decodable, Cloneable {
|
public class VehicleEngine: Object, Decodable, Cloneable {
|
||||||
@Persisted public var number: String?
|
@Persisted public var number: String?
|
||||||
@Persisted public var volume: Int? = 0
|
@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 powerKw: Float? = 0
|
||||||
@Persisted public var fuelType: String?
|
@Persisted public var fuelType: String?
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public class VehicleEngine: Object, Decodable, Cloneable {
|
|||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
self.number = try container.decodeIfPresent(String.self, forKey: .number)
|
self.number = try container.decodeIfPresent(String.self, forKey: .number)
|
||||||
self.volume = try container.decodeIfPresent(Int.self, forKey: .volume)
|
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.powerKw = try container.decodeIfPresent(Float.self, forKey: .powerKw)
|
||||||
self.fuelType = try container.decodeIfPresent(String.self, forKey: .fuelType)
|
self.fuelType = try container.decodeIfPresent(String.self, forKey: .fuelType)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user