WIP: Swift 3.2

This commit is contained in:
John Estropia
2017-06-07 20:07:43 +09:00
parent f9b6dd0c6a
commit 7f9a915d71
37 changed files with 199 additions and 200 deletions

View File

@@ -55,11 +55,6 @@ import CoreData
*/
public protocol ImportableUniqueObject: ImportableObject {
/**
The data type for the import source. This is most commonly an json type, `NSDictionary`, or another external source such as `NSUserDefaults`.
*/
associatedtype ImportSource
/**
The data type for the entity's unique ID attribute
*/
@@ -125,6 +120,26 @@ public protocol ImportableUniqueObject: ImportableObject {
public extension ImportableUniqueObject {
var uniqueIDValue: UniqueIDType {
get {
return self.cs_toRaw().getValue(
forKvcKey: type(of: self).uniqueIDKeyPath,
didGetValue: { UniqueIDType.cs_fromImportableNativeType($0 as! UniqueIDType.ImportableNativeType)! }
)
}
set {
self.cs_toRaw()
.setValue(
newValue,
forKvcKey: type(of: self).uniqueIDKeyPath,
willSetValue: { ($0.cs_toImportableNativeType() as! CoreDataNativeType) }
)
}
}
static func shouldInsert(from source: ImportSource, in transaction: BaseDataTransaction) -> Bool {
return Self.shouldUpdate(from: source, in: transaction)
@@ -173,29 +188,3 @@ public extension ImportableUniqueObject {
try self.update(from: source, in: transaction)
}
}
// MARK: - ImportableUniqueObject (Default Implementations)
public extension ImportableUniqueObject where Self: DynamicObject {
var uniqueIDValue: UniqueIDType {
get {
return self.cs_toRaw().getValue(
forKvcKey: type(of: self).uniqueIDKeyPath,
didGetValue: { UniqueIDType.cs_fromImportableNativeType($0 as! UniqueIDType.ImportableNativeType)! }
)
}
set {
self.cs_toRaw()
.setValue(
newValue,
forKvcKey: type(of: self).uniqueIDKeyPath,
willSetValue: { ($0.cs_toImportableNativeType() as! CoreDataNativeType) }
)
}
}
}