fixed platform dependencies

This commit is contained in:
John Rommel Estropia
2016-06-17 01:24:19 +09:00
parent 76a2bc1da2
commit 2dc09289bf
33 changed files with 662 additions and 48 deletions

View File

@@ -27,6 +27,8 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - NSFetchedResultsController
public extension NSFetchedResultsController {
@@ -217,3 +219,5 @@ public extension NSFetchedResultsController {
)
}
}
#endif

View File

@@ -413,7 +413,17 @@ extension Bool: SelectValueResultType {
public static func fromResultObject(result: AnyObject) -> Bool? {
return (result as? NSNumber)?.boolValue
switch result {
case let decimal as NSDecimalNumber:
return NSNumber(double: decimal.doubleValue).boolValue
case let number as NSNumber:
return number.boolValue
default:
return nil
}
}
}

View File

@@ -27,9 +27,10 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - CoreStoreFetchedResultsController
@available(OSX, unavailable)
internal final class CoreStoreFetchedResultsController: NSFetchedResultsController {
// MARK: Internal
@@ -108,3 +109,5 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
@nonobjc
private let reapplyAffectedStores: (fetchRequest: NSFetchRequest, context: NSManagedObjectContext) -> Bool
}
#endif

View File

@@ -27,9 +27,10 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - FetchedResultsControllerHandler
@available(OSX, unavailable)
internal protocol FetchedResultsControllerHandler: class {
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?)
@@ -46,7 +47,6 @@ internal protocol FetchedResultsControllerHandler: class {
// MARK: - FetchedResultsControllerDelegate
@available(OSX, unavailable)
internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResultsControllerDelegate {
// MARK: Internal
@@ -229,3 +229,5 @@ internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResult
@nonobjc
private var insertedSections = Set<Int>()
}
#endif

View File

@@ -68,6 +68,9 @@ internal extension NSManagedObjectContext {
context.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
context.undoManager = nil
context.setupForCoreStoreWithContextName("com.corestore.rootcontext")
#if os(iOS) || os(OSX)
context.observerForDidImportUbiquitousContentChangesNotification = NotificationObserver(
notificationName: NSPersistentStoreDidImportUbiquitousContentChangesNotification,
object: coordinator,
@@ -84,6 +87,9 @@ internal extension NSManagedObjectContext {
}
}
)
#endif
return context
}

View File

@@ -24,6 +24,7 @@
//
import Foundation
import CoreData
// MARK: - AsynchronousDataTransaction
@@ -233,6 +234,8 @@ extension GroupBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertible
}
#if os(iOS) || os(OSX)
// MARK: - ICloudStore
extension ICloudStore: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
@@ -258,6 +261,8 @@ extension ICloudStore: CustomDebugStringConvertible, CoreStoreDebugStringConvert
)
}
}
#endif
// MARK: - InMemoryStore
@@ -339,6 +344,8 @@ extension LegacySQLiteStore: CustomDebugStringConvertible, CoreStoreDebugStringC
}
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - ListMonitor
private struct CoreStoreFetchedSectionInfoWrapper: CoreStoreDebugStringConvertible {
@@ -377,6 +384,7 @@ extension ListMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvert
)
}
}
#endif
// MARK: - LocalStorageOptions
@@ -546,6 +554,8 @@ extension MigrationType: CustomDebugStringConvertible, CoreStoreDebugStringConve
}
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - ObjectMonitor
extension ObjectMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
@@ -569,7 +579,7 @@ extension ObjectMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConve
)
}
}
#endif
// MARK: - OrderBy
@@ -629,6 +639,8 @@ extension SaveResult: CustomDebugStringConvertible, CoreStoreDebugStringConverti
}
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - SectionBy
extension SectionBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
@@ -651,6 +663,7 @@ extension SectionBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertib
)
}
}
#endif
// MARK: - Select
@@ -1093,7 +1106,7 @@ extension NSEntityDescription: CoreStoreDebugStringConvertible {
("renamingIdentifier", self.renamingIdentifier),
("compoundIndexes", self.compoundIndexes)
]
if #available(iOS 9.0, *) {
if #available(iOS 9.0, OSXApplicationExtension 10.11, *) {
info.append(("uniquenessConstraints", self.uniquenessConstraints))
}

View File

@@ -27,9 +27,10 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - CSCoreStore
@available(OSX, unavailable)
public extension CSCoreStore {
/**
@@ -114,3 +115,5 @@ public extension CSCoreStore {
)
}
}
#endif

View File

@@ -27,9 +27,10 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - CSDataStack
@available(OSX, unavailable)
public extension CSDataStack {
/**
@@ -181,3 +182,5 @@ public extension CSDataStack {
)
}
}
#endif

View File

@@ -27,6 +27,8 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - CSListMonitor
/**
@@ -34,7 +36,6 @@ import CoreData
- SeeAlso: `ListMonitor`
*/
@available(OSX, unavailable)
@objc
public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
@@ -568,3 +569,5 @@ extension ListMonitor: CoreStoreSwiftType {
return CSListMonitor(self)
}
}
#endif

View File

@@ -27,6 +27,8 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - CSListObserver
/**
@@ -40,7 +42,6 @@ import CoreData
- SeeAlso: `ListObserver`
*/
@available(OSX, unavailable)
@objc
public protocol CSListObserver: class, AnyObject {
@@ -91,7 +92,6 @@ public protocol CSListObserver: class, AnyObject {
- SeeAlso: `ListObjectObserver`
*/
@available(OSX, unavailable)
@objc
public protocol CSListObjectObserver: CSListObserver {
@@ -152,7 +152,6 @@ public protocol CSListObjectObserver: CSListObserver {
- SeeAlso: `ListSectionObserver`
*/
@available(OSX, unavailable)
@objc
public protocol CSListSectionObserver: CSListObjectObserver {
@@ -176,3 +175,5 @@ public protocol CSListSectionObserver: CSListObjectObserver {
@objc
optional func listMonitor(monitor: CSListMonitor, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int)
}
#endif

View File

@@ -27,6 +27,8 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - CSObjectMonitor
/**
@@ -34,7 +36,6 @@ import CoreData
- SeeAlso: `ObjectMonitor`
*/
@available(OSX, unavailable)
@objc
public final class CSObjectMonitor: NSObject, CoreStoreObjectiveCType {
@@ -146,3 +147,5 @@ extension ObjectMonitor: CoreStoreSwiftType {
return CSObjectMonitor(self)
}
}
#endif

View File

@@ -27,6 +27,8 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - CSObjectObserver
/**
@@ -38,7 +40,6 @@ import CoreData
- SeeAlso: `ObjectObserver`
*/
@available(OSX, unavailable)
@objc
public protocol CSObjectObserver: class, AnyObject {
@@ -70,3 +71,5 @@ public protocol CSObjectObserver: class, AnyObject {
@objc
optional func objectMonitor(monitor: CSObjectMonitor, didDeleteObject object: AnyObject)
}
#endif

View File

@@ -27,6 +27,8 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - CSSectionBy
/**
@@ -34,7 +36,6 @@ import CoreData
- SeeAlso: `SectionBy`
*/
@available(OSX, unavailable)
@objc
public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
@@ -92,3 +93,5 @@ extension SectionBy: CoreStoreSwiftType {
public typealias ObjectiveCType = CSSectionBy
}
#endif

View File

@@ -27,9 +27,10 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - NSFetchedResultsController
@available(OSX, unavailable)
public extension NSFetchedResultsController {
/**
@@ -61,3 +62,5 @@ public extension NSFetchedResultsController {
)
}
}
#endif

View File

@@ -27,9 +27,10 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - CoreStore
@available(OSX, unavailable)
public extension CoreStore {
/**
@@ -148,3 +149,5 @@ public extension CoreStore {
self.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}
}
#endif

View File

@@ -30,9 +30,10 @@ import CoreData
#endif
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - DataStack
@available(OSX, unavailable)
public extension DataStack {
/**
@@ -227,3 +228,5 @@ public extension DataStack {
)
}
}
#endif

View File

@@ -30,6 +30,8 @@ import CoreData
#endif
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - ListMonitor
/**
@@ -69,7 +71,6 @@ import CoreData
```
In the example above, both `person1` and `person2` will contain the object at section=2, index=3.
*/
@available(OSX, unavailable)
public final class ListMonitor<T: NSManagedObject>: Hashable {
// MARK: Public (Accessors)
@@ -1163,41 +1164,35 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
// MARK: - ListMonitor: Equatable
@available(OSX, unavailable)
@warn_unused_result
public func == <T: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<T>) -> Bool {
return lhs === rhs
}
@available(OSX, unavailable)
@warn_unused_result
public func == <T: NSManagedObject, U: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<U>) -> Bool {
return lhs.fetchedResultsController === rhs.fetchedResultsController
}
@available(OSX, unavailable)
@warn_unused_result
public func ~= <T: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<T>) -> Bool {
return lhs === rhs
}
@available(OSX, unavailable)
@warn_unused_result
public func ~= <T: NSManagedObject, U: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<U>) -> Bool {
return lhs.fetchedResultsController === rhs.fetchedResultsController
}
@available(OSX, unavailable)
extension ListMonitor: Equatable { }
// MARK: - ListMonitor: FetchedResultsControllerHandler
@available(OSX, unavailable)
extension ListMonitor: FetchedResultsControllerHandler {
// MARK: FetchedResultsControllerHandler
@@ -1324,3 +1319,5 @@ private let UserInfoKeyNewIndexPath = "UserInfoKeyNewIndexPath"
private let UserInfoKeySectionInfo = "UserInfoKeySectionInfo"
private let UserInfoKeySectionIndex = "UserInfoKeySectionIndex"
#endif

View File

@@ -27,6 +27,8 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - ListObserver
/**
@@ -39,7 +41,6 @@ import CoreData
monitor.addObserver(self)
```
*/
@available(OSX, unavailable)
public protocol ListObserver: class {
/**
@@ -79,7 +80,6 @@ public protocol ListObserver: class {
// MARK: - ListObserver (Default Implementations)
@available(OSX, unavailable)
public extension ListObserver {
/**
@@ -116,7 +116,6 @@ public extension ListObserver {
monitor.addObserver(self)
```
*/
@available(OSX, unavailable)
public protocol ListObjectObserver: ListObserver {
/**
@@ -160,7 +159,6 @@ public protocol ListObjectObserver: ListObserver {
// MARK: - ListObjectObserver (Default Implementations)
@available(OSX, unavailable)
public extension ListObjectObserver {
/**
@@ -198,7 +196,6 @@ public extension ListObjectObserver {
monitor.addObserver(self)
```
*/
@available(OSX, unavailable)
public protocol ListSectionObserver: ListObjectObserver {
/**
@@ -223,7 +220,6 @@ public protocol ListSectionObserver: ListObjectObserver {
// MARK: - ListSectionObserver (Default Implementations)
@available(OSX, unavailable)
public extension ListSectionObserver {
/**
@@ -236,3 +232,5 @@ public extension ListSectionObserver {
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) { }
}
#endif

View File

@@ -30,6 +30,8 @@ import CoreData
#endif
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - ObjectMonitor
/**
@@ -42,7 +44,6 @@ import CoreData
Observers registered via `addObserver(_:)` are not retained. `ObjectMonitor` only keeps a `weak` reference to all observers, thus keeping itself free from retain-cycles.
*/
@available(OSX, unavailable)
public final class ObjectMonitor<T: NSManagedObject> {
/**
@@ -300,25 +301,21 @@ public final class ObjectMonitor<T: NSManagedObject> {
// MARK: - ObjectMonitor: Equatable
@available(OSX, unavailable)
public func == <T: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<T>) -> Bool {
return lhs === rhs
}
@available(OSX, unavailable)
public func ~= <T: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<T>) -> Bool {
return lhs === rhs
}
@available(OSX, unavailable)
extension ObjectMonitor: Equatable { }
// MARK: - ObjectMonitor: FetchedResultsControllerHandler
@available(OSX, unavailable)
extension ObjectMonitor: FetchedResultsControllerHandler {
// MARK: FetchedResultsControllerHandler
@@ -371,3 +368,4 @@ private let ObjectMonitorDidUpdateObjectNotification = "ObjectMonitorDidUpdateOb
private let UserInfoKeyObject = "UserInfoKeyObject"
#endif

View File

@@ -27,6 +27,8 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - ObjectObserver
/**
@@ -36,7 +38,6 @@ import CoreData
monitor.addObserver(self)
```
*/
@available(OSX, unavailable)
public protocol ObjectObserver: class {
/**
@@ -73,7 +74,6 @@ public protocol ObjectObserver: class {
// MARK: - ObjectObserver (Default Implementations)
@available(OSX, unavailable)
public extension ObjectObserver {
/**
@@ -91,3 +91,5 @@ public extension ObjectObserver {
*/
func objectMonitor(monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType) { }
}
#endif

View File

@@ -27,6 +27,8 @@ import Foundation
import CoreData
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - SectionBy
/**
@@ -39,7 +41,6 @@ import CoreData
)
```
*/
@available(OSX, unavailable)
public struct SectionBy {
/**
@@ -71,3 +72,5 @@ public struct SectionBy {
internal let sectionKeyPath: KeyPath
internal let sectionIndexTransformer: (sectionName: KeyPath?) -> String?
}
#endif

View File

@@ -30,9 +30,10 @@ import CoreData
#endif
#if os(iOS) || os(watchOS) || os(tvOS)
// MARK: - UnsafeDataTransaction
@available(OSX, unavailable)
public extension UnsafeDataTransaction {
/**
@@ -208,3 +209,5 @@ public extension UnsafeDataTransaction {
)
}
}
#endif

View File

@@ -27,6 +27,8 @@ import Foundation
import CoreData
#if os(iOS) || os(OSX)
// MARK: - ICloudStore
/**
@@ -502,3 +504,5 @@ private let ICloudUbiquitousStoreWillRemoveContentNotification = "ICloudUbiquito
private let ICloudUbiquitousStoreDidRemoveContentNotification = "ICloudUbiquitousStoreDidRemoveContentNotification"
private let UserInfoKeyDataStack = "UserInfoKeyDataStack"
#endif

View File

@@ -26,6 +26,8 @@
import Foundation
#if os(iOS) || os(OSX)
// MARK: - ICloudStoreObserver
/**
@@ -120,3 +122,5 @@ public extension ICloudStoreObserver {
public func iCloudStoreDidRemoveContent(storage storage: ICloudStore, dataStack: DataStack) {}
}
#endif

View File

@@ -24,6 +24,7 @@
//
import Foundation
import CoreData
// MARK: - LegacySQLiteStore