mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-21 17:09:10 +01:00
WIP: Xcode 8 beta 6
This commit is contained in:
@@ -434,9 +434,9 @@ public class ICloudStore: CloudStorage {
|
||||
let options = [
|
||||
NSSQLitePragmasOption: ["journal_mode": "DELETE"],
|
||||
NSPersistentStoreRemoveUbiquitousMetadataOption: true
|
||||
]
|
||||
] as [String : Any]
|
||||
let store = try journalUpdatingCoordinator.addPersistentStore(
|
||||
ofType: self.dynamicType.storeType,
|
||||
ofType: type(of: self).storeType,
|
||||
configurationName: self.configuration,
|
||||
at: cacheFileURL,
|
||||
options: options
|
||||
@@ -470,7 +470,7 @@ public class ICloudStore: CloudStorage {
|
||||
|
||||
private weak var dataStack: DataStack?
|
||||
|
||||
private func registerNotification<T: ICloudStoreObserver>(_ notificationKey: UnsafePointer<Void>, name: Notification.Name, toObserver observer: T, callback: (observer: T, storage: ICloudStore, dataStack: DataStack) -> Void) {
|
||||
private func registerNotification<T: ICloudStoreObserver>(_ notificationKey: UnsafeRawPointer, name: Notification.Name, toObserver observer: T, callback: @escaping (_ observer: T, _ storage: ICloudStore, _ dataStack: DataStack) -> Void) {
|
||||
|
||||
cs_setAssociatedRetainedObject(
|
||||
NotificationObserver(
|
||||
@@ -485,7 +485,7 @@ public class ICloudStore: CloudStorage {
|
||||
|
||||
return
|
||||
}
|
||||
callback(observer: observer, storage: self, dataStack: dataStack)
|
||||
callback(observer, self, dataStack)
|
||||
}
|
||||
),
|
||||
forKey: notificationKey,
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
#if USE_FRAMEWORKS
|
||||
import GCDKit
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: - LegacySQLiteStore
|
||||
@@ -177,7 +174,7 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
|
||||
let journalUpdatingCoordinator = NSPersistentStoreCoordinator(managedObjectModel: soureModel)
|
||||
let store = try journalUpdatingCoordinator.addPersistentStore(
|
||||
ofType: self.dynamicType.storeType,
|
||||
ofType: type(of: self).storeType,
|
||||
configurationName: self.configuration,
|
||||
at: fileURL,
|
||||
options: [NSSQLitePragmasOption: ["journal_mode": "DELETE"]]
|
||||
@@ -197,7 +194,7 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
attributes: nil
|
||||
)
|
||||
try fileManager.moveItem(at: fileURL, to: temporaryFile)
|
||||
GCDQueue.background.async {
|
||||
DispatchQueue.global(qos: .background).async {
|
||||
|
||||
_ = try? fileManager.removeItem(at: temporaryFile)
|
||||
}
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
//
|
||||
|
||||
import CoreData
|
||||
#if USE_FRAMEWORKS
|
||||
import GCDKit
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: - SQLiteStore
|
||||
@@ -174,7 +171,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
|
||||
let journalUpdatingCoordinator = NSPersistentStoreCoordinator(managedObjectModel: soureModel)
|
||||
let store = try journalUpdatingCoordinator.addPersistentStore(
|
||||
ofType: self.dynamicType.storeType,
|
||||
ofType: type(of: self).storeType,
|
||||
configurationName: self.configuration,
|
||||
at: fileURL,
|
||||
options: [NSSQLitePragmasOption: ["journal_mode": "DELETE"]]
|
||||
@@ -194,7 +191,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
attributes: nil
|
||||
)
|
||||
try fileManager.moveItem(at: fileURL, to: temporaryFile)
|
||||
GCDQueue.background.async {
|
||||
DispatchQueue.global(qos: .background).async {
|
||||
|
||||
_ = try? fileManager.removeItem(at: temporaryFile)
|
||||
}
|
||||
@@ -226,9 +223,9 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
)
|
||||
}()
|
||||
|
||||
internal static let defaultFileURL = try! SQLiteStore.defaultRootDirectory
|
||||
internal static let defaultFileURL = SQLiteStore.defaultRootDirectory
|
||||
.appendingPathComponent(
|
||||
(Bundle.main.objectForInfoDictionaryKey("CFBundleName") as? String) ?? "CoreData",
|
||||
(Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String) ?? "CoreData",
|
||||
isDirectory: false
|
||||
)
|
||||
.appendingPathExtension("sqlite")
|
||||
|
||||
@@ -82,7 +82,7 @@ public protocol DefaultInitializableStore: StorageInterface {
|
||||
/**
|
||||
The `LocalStorageOptions` provides settings that tells the `DataStack` how to setup the persistent store for `LocalStorage` implementers.
|
||||
*/
|
||||
public struct LocalStorageOptions: OptionSet, NilLiteralConvertible {
|
||||
public struct LocalStorageOptions: OptionSet, ExpressibleByNilLiteral {
|
||||
|
||||
/**
|
||||
Tells the `DataStack` that the store should not be migrated or recreated, and should simply fail on model mismatch
|
||||
@@ -119,7 +119,7 @@ public struct LocalStorageOptions: OptionSet, NilLiteralConvertible {
|
||||
public let rawValue: Int
|
||||
|
||||
|
||||
// MARK: NilLiteralConvertible
|
||||
// MARK: ExpressibleByNilLiteral
|
||||
|
||||
public init(nilLiteral: ()) {
|
||||
|
||||
@@ -165,7 +165,7 @@ internal extension LocalStorage {
|
||||
|
||||
internal func matchesPersistentStore(_ persistentStore: NSPersistentStore) -> Bool {
|
||||
|
||||
return persistentStore.type == self.dynamicType.storeType
|
||||
return persistentStore.type == type(of: self).storeType
|
||||
&& persistentStore.configurationName == (self.configuration ?? Into.defaultConfigurationName)
|
||||
&& persistentStore.url == self.fileURL
|
||||
}
|
||||
@@ -177,7 +177,7 @@ internal extension LocalStorage {
|
||||
/**
|
||||
The `CloudStorageOptions` provides settings that tells the `DataStack` how to setup the persistent store for `LocalStorage` implementers.
|
||||
*/
|
||||
public struct CloudStorageOptions: OptionSet, NilLiteralConvertible {
|
||||
public struct CloudStorageOptions: OptionSet, ExpressibleByNilLiteral {
|
||||
|
||||
/**
|
||||
Tells the `DataStack` that the store should not be migrated or recreated, and should simply fail on model mismatch
|
||||
@@ -208,7 +208,7 @@ public struct CloudStorageOptions: OptionSet, NilLiteralConvertible {
|
||||
public let rawValue: Int
|
||||
|
||||
|
||||
// MARK: NilLiteralConvertible
|
||||
// MARK: ExpressibleByNilLiteral
|
||||
|
||||
public init(nilLiteral: ()) {
|
||||
|
||||
@@ -249,7 +249,7 @@ internal extension CloudStorage {
|
||||
|
||||
internal func matchesPersistentStore(_ persistentStore: NSPersistentStore) -> Bool {
|
||||
|
||||
guard persistentStore.type == self.dynamicType.storeType
|
||||
guard persistentStore.type == type(of: self).storeType
|
||||
&& persistentStore.configurationName == (self.configuration ?? Into.defaultConfigurationName) else {
|
||||
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user