mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-23 09:51:12 +01:00
added tool to convert existing NSManagedObjectModels to the new CoreStoreSchema
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
import CoreStore
|
||||
|
||||
// MARK: - AppDelegate
|
||||
|
||||
@@ -22,6 +23,47 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
application.statusBarStyle = .lightContent
|
||||
|
||||
/// Generated by CoreStore on 4/21/17, 2:41 PM
|
||||
class Place: CoreStoreObject {
|
||||
|
||||
let latitude = Value.Optional<Double>("latitude", default: 0.0)
|
||||
let title = Value.Optional<String>("title")
|
||||
let longitude = Value.Optional<Double>("longitude", default: 0.0)
|
||||
let subtitle = Value.Optional<String>("subtitle")
|
||||
}
|
||||
class Palette: CoreStoreObject {
|
||||
|
||||
let saturation = Value.Optional<Float>("saturation", default: 0.0)
|
||||
let hue = Value.Optional<Int32>("hue", default: 0)
|
||||
let brightness = Value.Optional<Float>("brightness", default: 0.0)
|
||||
let colorName = Value.Optional<String>("colorName", isTransient: true)
|
||||
}
|
||||
class TimeZone: CoreStoreObject {
|
||||
|
||||
let secondsFromGMT = Value.Optional<Int32>("secondsFromGMT", default: 0)
|
||||
let name = Value.Optional<String>("name")
|
||||
let daylightSavingTimeOffset = Value.Optional<Double>("daylightSavingTimeOffset", default: 0.0)
|
||||
let abbreviation = Value.Optional<String>("abbreviation")
|
||||
let hasDaylightSavingTime = Value.Optional<Bool>("hasDaylightSavingTime")
|
||||
}
|
||||
|
||||
|
||||
|
||||
let schema = CoreStoreSchema(
|
||||
modelVersion: "CoreStoreDemo",
|
||||
entities: [
|
||||
Entity<Place>("Place"),
|
||||
Entity<Palette>("Palette"),
|
||||
Entity<TimeZone>("TimeZone"),
|
||||
],
|
||||
versionLock: [
|
||||
"Place": [0x25cb5bd001887b92, 0xfe86dd433a5e0430, 0xcca50ac3f3659b68, 0xfe4e494ff66439b0],
|
||||
"Palette": [0xa306515d026d3c43, 0x1b299716733e56f6, 0x53bff8954221a1b6, 0xa74d6b1e613923ab],
|
||||
"TimeZone": [0x92e08db969e46163, 0xae9cf1ab738868c5, 0xb6a269249771a562, 0x58a357eab4c99ed5]
|
||||
]
|
||||
)
|
||||
|
||||
print(schema.printCoreStoreSchema())
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class Palette: NSManagedObject {
|
||||
}
|
||||
set {
|
||||
|
||||
self.setValue(newValue, forKvcKey: #keyPath(Palette.colorName))
|
||||
self.setValue(newValue.cs_toImportableNativeType(), forKvcKey: #keyPath(Palette.colorName))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user