diff --git a/CoreStore.xcodeproj/project.pbxproj b/CoreStore.xcodeproj/project.pbxproj index 18dad5c..a0b9b84 100644 --- a/CoreStore.xcodeproj/project.pbxproj +++ b/CoreStore.xcodeproj/project.pbxproj @@ -2627,6 +2627,7 @@ SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; @@ -2680,6 +2681,7 @@ SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; @@ -2955,7 +2957,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; }; name = Debug; @@ -2979,7 +2981,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; }; name = Release; diff --git a/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj b/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj index c92f2aa..186cbd5 100644 --- a/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj +++ b/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj @@ -408,6 +408,7 @@ SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -447,6 +448,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; }; name = Release; diff --git a/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift index f1d7d4d..cfee272 100644 --- a/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift @@ -230,15 +230,15 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo ) ] - private let queryingItems = [ + private let queryingItems: [(title: String, query: () -> Any)] = [ ( title: "Number of Time Zones", query: { () -> Any in return Static.timeZonesStack.queryValue( - From(), - Select(.count(#keyPath(TimeZone.name))) - )! + From() + .select(NSNumber.self, .count(#keyPath(TimeZone.name))) + )! as Any } ), ( @@ -246,10 +246,10 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo query: { () -> Any in return Static.timeZonesStack.queryValue( - From(), - Select(#keyPath(TimeZone.abbreviation)), - Where("%K ENDSWITH[c] %@", #keyPath(TimeZone.name), "Tokyo") - )! + From() + .select(String.self, .attribute(#keyPath(TimeZone.abbreviation))) + .where(format: "%K ENDSWITH[c] %@", #keyPath(TimeZone.name), "Tokyo") + )! as Any } ), ( @@ -257,9 +257,13 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo query: { () -> Any in return Static.timeZonesStack.queryAttributes( - From(), - Select(#keyPath(TimeZone.name), #keyPath(TimeZone.abbreviation)), - OrderBy(.ascending(#keyPath(TimeZone.name))) + From() + .select( + NSDictionary.self, + .attribute(#keyPath(TimeZone.name)), + .attribute(#keyPath(TimeZone.abbreviation)) + ) + .orderBy(.ascending(#keyPath(TimeZone.name))) )! } ), @@ -268,10 +272,17 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo query: { () -> Any in return Static.timeZonesStack.queryAttributes( - From(), - Select(.count(#keyPath(TimeZone.abbreviation)), #keyPath(TimeZone.abbreviation)), - GroupBy(#keyPath(TimeZone.abbreviation)), - OrderBy(.ascending(#keyPath(TimeZone.secondsFromGMT)), .ascending(#keyPath(TimeZone.name))) + From() + .select( + NSDictionary.self, + .count(#keyPath(TimeZone.abbreviation)), + .attribute(#keyPath(TimeZone.abbreviation)) + ) + .groupBy(#keyPath(TimeZone.abbreviation)) + .orderBy( + .ascending(#keyPath(TimeZone.secondsFromGMT)), + .ascending(#keyPath(TimeZone.name)) + ) )! } ), @@ -285,8 +296,8 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo .count(#keyPath(TimeZone.hasDaylightSavingTime), as: "numberOfCountries"), #keyPath(TimeZone.hasDaylightSavingTime) ), - GroupBy(#keyPath(TimeZone.hasDaylightSavingTime)), - OrderBy(.descending(#keyPath(TimeZone.hasDaylightSavingTime))) + GroupBy(#keyPath(TimeZone.hasDaylightSavingTime)), + OrderBy(.descending(#keyPath(TimeZone.hasDaylightSavingTime))) )! } ) diff --git a/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift index baffca5..9227773 100644 --- a/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift @@ -370,8 +370,8 @@ class MigrationsDemoViewController: UIViewController, ListObserver, UITableViewD self._dataStack = dataStack let listMonitor = dataStack.monitorList( - From(model.entityType) - .orderBy(.descending(#keyPath(OrganismV1.dna))) + From(model.entityType), + OrderBy(.descending(#keyPath(OrganismV1.dna))) ) listMonitor.addObserver(self) self._listMonitor = listMonitor diff --git a/Sources/ChainedClauseBuilder.swift b/Sources/ChainedClauseBuilder.swift index 432cdbb..7974877 100644 --- a/Sources/ChainedClauseBuilder.swift +++ b/Sources/ChainedClauseBuilder.swift @@ -45,6 +45,7 @@ public protocol QueryChainableBuilderType { var queryClauses: [QueryClause] { get set } } +@available(OSX 10.12, *) public protocol SectionMonitorBuilderType { associatedtype ObjectType: DynamicObject @@ -85,6 +86,7 @@ public struct QueryChainBuilder: QueryCha // MARK: - SectionMonitorChainBuilder +@available(OSX 10.12, *) public struct SectionMonitorChainBuilder: SectionMonitorBuilderType { // MARK: SectionMonitorBuilderType @@ -113,11 +115,13 @@ public extension From { ) } + @available(OSX 10.12, *) public func sectionBy(_ sectionKeyPath: KeyPathString) -> SectionMonitorChainBuilder { return self.sectionBy(sectionKeyPath, { $0 }) } + @available(OSX 10.12, *) public func sectionBy(_ sectionKeyPath: KeyPathString, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { return .init( @@ -270,6 +274,7 @@ public extension QueryChainBuilder { } } +@available(OSX 10.12, *) public extension SectionMonitorChainBuilder { public func `where`(_ clause: Where) -> SectionMonitorChainBuilder {