keyPath utilities for SectionBy clauses

This commit is contained in:
John Rommel Estropia
2017-09-24 10:38:17 +09:00
parent e814733ae9
commit 645034dde5
12 changed files with 207 additions and 58 deletions

View File

@@ -36,7 +36,7 @@ import CoreData
*/
@available(OSX 10.12, *)
@objc
public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
public final class CSSectionBy: NSObject {
/**
Initializes a `CSSectionBy` clause with the key path to use to group `CSListMonitor` objects into sections
@@ -47,7 +47,7 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
@objc
public static func keyPath(_ sectionKeyPath: KeyPathString) -> CSSectionBy {
return self.init(SectionBy(sectionKeyPath))
return self.init(SectionBy<NSManagedObject>(sectionKeyPath))
}
/**
@@ -60,7 +60,7 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
@objc
public static func keyPath(_ sectionKeyPath: KeyPathString, sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> CSSectionBy {
return self.init(SectionBy(sectionKeyPath, sectionIndexTransformer))
return self.init(SectionBy<NSManagedObject>(sectionKeyPath, sectionIndexTransformer))
}
@@ -74,11 +74,11 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
// MARK: CoreStoreObjectiveCType
public let bridgeToSwift: SectionBy
public let bridgeToSwift: SectionBy<NSManagedObject>
public init(_ swiftValue: SectionBy) {
public init<D>(_ swiftValue: SectionBy<D>) {
self.bridgeToSwift = swiftValue
self.bridgeToSwift = swiftValue.downcast()
super.init()
}
}
@@ -87,7 +87,7 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
// MARK: - SectionBy
@available(OSX 10.12, *)
extension SectionBy: CoreStoreSwiftType {
extension SectionBy {
// MARK: CoreStoreSwiftType
@@ -95,4 +95,12 @@ extension SectionBy: CoreStoreSwiftType {
return CSSectionBy(self)
}
// MARK: FilePrivate
fileprivate func downcast() -> SectionBy<NSManagedObject> {
return SectionBy<NSManagedObject>(self.sectionKeyPath, self.sectionIndexTransformer)
}
}