mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-25 19:01:16 +01:00
WIP: objective C interface
This commit is contained in:
@@ -40,7 +40,7 @@ public extension CSCoreStore {
|
||||
/**
|
||||
Creates an `CSSQLiteStore` with default parameters and adds it to the `defaultStack`. This method blocks until completion.
|
||||
```
|
||||
try CSCoreStore.addStorageAndWait()
|
||||
CSSQLiteStore *storage = [CSCoreStore addStorageAndWaitAndReturnError:&error];
|
||||
```
|
||||
|
||||
- returns: the local SQLite storage added to the `defaultStack`
|
||||
@@ -54,17 +54,19 @@ public extension CSCoreStore {
|
||||
/**
|
||||
Adds a `StorageInterface` to the `defaultStack` and blocks until completion.
|
||||
```
|
||||
try CoreStore.addStorageAndWait(InMemoryStore(configuration: "Config1"))
|
||||
CSInMemoryStore *storage = [CoreStore
|
||||
addStorageAndWait: [[InMemoryStore alloc] initWithConfiguration: @"Config1"]
|
||||
error: &error];
|
||||
```
|
||||
|
||||
- parameter storage: the `StorageInterface`
|
||||
- returns: the `StorageInterface` added to the `defaultStack`
|
||||
*/
|
||||
// @objc
|
||||
// public static func addStorageAndWait(storage: StorageInterface) throws -> StorageInterface {
|
||||
//
|
||||
// return try self.defaultStack.swift.addStorageAndWait(storage)
|
||||
// }
|
||||
@objc
|
||||
public static func addStorageAndWait(storage: CSInMemoryStore) throws -> CSInMemoryStore {
|
||||
|
||||
return try CoreStore.defaultStack.addStorageAndWait(storage.swift).objc
|
||||
}
|
||||
|
||||
/**
|
||||
Creates a `LocalStorageface` of the specified store type with default values and adds it to the `defaultStack`. This method blocks until completion.
|
||||
|
||||
@@ -33,7 +33,7 @@ extension DataStack: CoreStoreBridgeable {
|
||||
|
||||
// MARK: CoreStoreBridgeable
|
||||
|
||||
public typealias NativeType = CSDataStack
|
||||
public typealias ObjCType = CSDataStack
|
||||
}
|
||||
|
||||
|
||||
@@ -62,12 +62,12 @@ public final class CSDataStack: NSObject, CoreStoreBridge {
|
||||
- parameter versionChain: the version strings that indicate the sequence of model versions to be used as the order for progressive migrations. If not specified, will default to a non-migrating data stack.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(modelName: String = DataStack.applicationName, bundle: NSBundle = NSBundle.mainBundle(), versionChain: [String]? = nil) {
|
||||
public convenience init(modelName: String?, bundle: NSBundle?, versionChain: [String]?) {
|
||||
|
||||
self.init(
|
||||
DataStack(
|
||||
modelName: modelName,
|
||||
bundle: bundle,
|
||||
modelName: modelName ?? DataStack.applicationName,
|
||||
bundle: bundle ?? NSBundle.mainBundle(),
|
||||
migrationChain: versionChain.flatMap { MigrationChain($0) } ?? nil
|
||||
)
|
||||
)
|
||||
@@ -81,12 +81,12 @@ public final class CSDataStack: NSObject, CoreStoreBridge {
|
||||
- parameter versionTree: the version strings that indicate the sequence of model versions to be used as the order for progressive migrations. If not specified, will default to a non-migrating data stack.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(modelName: String = DataStack.applicationName, bundle: NSBundle = NSBundle.mainBundle(), versionTree: [String: String]? = nil) {
|
||||
public convenience init(modelName: String?, bundle: NSBundle?, versionTree: [String: String]?) {
|
||||
|
||||
self.init(
|
||||
DataStack(
|
||||
modelName: modelName,
|
||||
bundle: bundle,
|
||||
modelName: modelName ?? DataStack.applicationName,
|
||||
bundle: bundle ?? NSBundle.mainBundle(),
|
||||
migrationChain: versionTree.flatMap { MigrationChain($0) } ?? nil
|
||||
)
|
||||
)
|
||||
@@ -99,7 +99,7 @@ public final class CSDataStack: NSObject, CoreStoreBridge {
|
||||
- parameter versionChain: the `MigrationChain` that indicates the sequence of model versions to be used as the order for progressive migrations. If not specified, will default to a non-migrating data stack.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(model: NSManagedObjectModel, versionChain: [String]? = nil) {
|
||||
public convenience init(model: NSManagedObjectModel, versionChain: [String]?) {
|
||||
|
||||
self.init(
|
||||
DataStack(
|
||||
@@ -116,7 +116,7 @@ public final class CSDataStack: NSObject, CoreStoreBridge {
|
||||
- parameter versionTree: the `MigrationChain` that indicates the sequence of model versions to be used as the order for progressive migrations. If not specified, will default to a non-migrating data stack.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(model: NSManagedObjectModel, versionTree: [String]? = nil) {
|
||||
public convenience init(model: NSManagedObjectModel, versionTree: [String]?) {
|
||||
|
||||
self.init(
|
||||
DataStack(
|
||||
|
||||
121
Sources/ObjectiveC/CSInMemoryStore.swift
Normal file
121
Sources/ObjectiveC/CSInMemoryStore.swift
Normal file
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// CSInMemoryStore.swift
|
||||
// CoreStore
|
||||
//
|
||||
// Copyright © 2016 John Rommel Estropia
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
|
||||
// MARK: - InMemoryStore
|
||||
|
||||
extension InMemoryStore: CoreStoreBridgeable {
|
||||
|
||||
// MARK: CoreStoreBridgeable
|
||||
|
||||
public typealias ObjCType = CSInMemoryStore
|
||||
}
|
||||
|
||||
|
||||
// MARK: - CSInMemoryStore
|
||||
|
||||
/**
|
||||
The `CSInMemoryStore` serves as the Objective-C bridging type for `InMemoryStore`.
|
||||
*/
|
||||
@objc
|
||||
public final class CSInMemoryStore: NSObject, CoreStoreBridge {
|
||||
|
||||
/**
|
||||
Initializes a `CSInMemoryStore` for the specified configuration
|
||||
|
||||
- parameter configuration: an optional configuration name from the model file. If not specified, defaults to `nil`, the "Default" configuration.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(configuration: String?) {
|
||||
|
||||
self.init(InMemoryStore(configuration: configuration))
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes a `CSInMemoryStore` with the "Default" configuration
|
||||
*/
|
||||
@objc
|
||||
public convenience override init() {
|
||||
|
||||
self.init(InMemoryStore())
|
||||
}
|
||||
|
||||
|
||||
// MARK: StorageInterface
|
||||
|
||||
/**
|
||||
The string identifier for the `NSPersistentStore`'s `type` property. For `CSInMemoryStore`s, this is always set to `NSInMemoryStoreType`.
|
||||
*/
|
||||
@objc
|
||||
public static let storeType = NSInMemoryStoreType
|
||||
|
||||
/**
|
||||
The configuration name in the model file
|
||||
*/
|
||||
@objc
|
||||
public var configuration: String? {
|
||||
|
||||
return self.swift.configuration
|
||||
}
|
||||
|
||||
/**
|
||||
The options dictionary for the `NSPersistentStore`. For `CSInMemoryStore`s, this is always set to `nil`.
|
||||
*/
|
||||
@objc
|
||||
public var storeOptions: [String: AnyObject]? {
|
||||
|
||||
return self.swift.storeOptions
|
||||
}
|
||||
|
||||
|
||||
// MARK: NSObject
|
||||
|
||||
public override var hash: Int {
|
||||
|
||||
return ObjectIdentifier(self.swift).hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSInMemoryStore else {
|
||||
|
||||
return false
|
||||
}
|
||||
return self.swift === object.swift
|
||||
}
|
||||
|
||||
|
||||
// MARK: CoreStoreBridge
|
||||
|
||||
public let swift: InMemoryStore
|
||||
|
||||
public required init(_ swiftObject: InMemoryStore) {
|
||||
|
||||
self.swift = swiftObject
|
||||
}
|
||||
}
|
||||
75
Sources/ObjectiveC/CSLegacySQLiteStore.swift
Normal file
75
Sources/ObjectiveC/CSLegacySQLiteStore.swift
Normal file
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// CSLegacySQLiteStore.swift
|
||||
// CoreStore
|
||||
//
|
||||
// Copyright © 2016 John Rommel Estropia
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
|
||||
// MARK: - LegacySQLiteStore
|
||||
|
||||
extension LegacySQLiteStore: CoreStoreBridgeable {
|
||||
|
||||
// MARK: CoreStoreBridgeable
|
||||
|
||||
public typealias ObjCType = CSLegacySQLiteStore
|
||||
}
|
||||
|
||||
|
||||
// MARK: - CSSQLiteStore
|
||||
|
||||
/**
|
||||
The `CSLegacySQLiteStore` serves as the Objective-C bridging type for `LegacySQLiteStore`.
|
||||
*/
|
||||
@objc
|
||||
public final class CSLegacySQLiteStore: NSObject, CoreStoreBridge {
|
||||
|
||||
|
||||
|
||||
// MARK: NSObject
|
||||
|
||||
public override var hash: Int {
|
||||
|
||||
return ObjectIdentifier(self.swift).hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSLegacySQLiteStore else {
|
||||
|
||||
return false
|
||||
}
|
||||
return self.swift === object.swift
|
||||
}
|
||||
|
||||
|
||||
// MARK: CoreStoreBridge
|
||||
|
||||
public let swift: LegacySQLiteStore
|
||||
|
||||
public required init(_ swiftObject: LegacySQLiteStore) {
|
||||
|
||||
self.swift = swiftObject
|
||||
}
|
||||
}
|
||||
@@ -33,18 +33,139 @@ extension SQLiteStore: CoreStoreBridgeable {
|
||||
|
||||
// MARK: CoreStoreBridgeable
|
||||
|
||||
public typealias NativeType = CSSQLiteStore
|
||||
public typealias ObjCType = CSSQLiteStore
|
||||
}
|
||||
|
||||
|
||||
// MARK: - CSSQLiteStore
|
||||
|
||||
/**
|
||||
The `CSSQLiteStore` serves as the Objective-C bridging type for `SQLiteStore`.
|
||||
The `CSSQLiteStore` serves as the Objective-C bridging type for `CSSQLiteStore`.
|
||||
*/
|
||||
@objc
|
||||
public final class CSSQLiteStore: NSObject, CoreStoreBridge {
|
||||
|
||||
/**
|
||||
Initializes an SQLite store interface from the given SQLite file URL. When this instance is passed to the `CSDataStack`'s `addStorage()` methods, a new SQLite file will be created if it does not exist.
|
||||
|
||||
- parameter fileURL: the local file URL for the target SQLite persistent store. Note that if you have multiple configurations, you will need to specify a different `fileURL` explicitly for each of them.
|
||||
- parameter configuration: an optional configuration name from the model file. If not specified, defaults to `nil`, the "Default" configuration. Note that if you have multiple configurations, you will need to specify a different `fileURL` explicitly for each of them.
|
||||
- parameter mappingModelBundles: a list of `NSBundle`s from which to search mapping models for migration.
|
||||
- parameter localStorageOptions: When the `CSSQLiteStore` is passed to the `CSDataStack`'s `addStorage()` methods, tells the `CSDataStack` how to setup the persistent store. Defaults to `.None`.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(fileURL: NSURL, configuration: String?, mappingModelBundles: [NSBundle]?, localStorageOptions: CSLocalStorageOptions) {
|
||||
|
||||
self.init(
|
||||
SQLiteStore(
|
||||
fileURL: fileURL,
|
||||
configuration: configuration,
|
||||
mappingModelBundles: mappingModelBundles ?? NSBundle.allBundles(),
|
||||
localStorageOptions: LocalStorageOptions(rawValue: localStorageOptions.rawValue)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes an SQLite store interface from the given SQLite file name. When this instance is passed to the `CSDataStack`'s `addStorage()` methods, a new SQLite file will be created if it does not exist.
|
||||
- Warning: The default SQLite file location for the `CSLegacySQLiteStore` and `CSSQLiteStore` are different. If the app was depending on CoreStore's default directories prior to 2.0.0, make sure to use `CSLegacySQLiteStore` instead of `CSSQLiteStore`.
|
||||
|
||||
- parameter fileName: the local filename for the SQLite persistent store in the "Application Support/<bundle id>" directory (or the "Caches/<bundle id>" directory on tvOS). Note that if you have multiple configurations, you will need to specify a different `fileName` explicitly for each of them.
|
||||
- parameter configuration: an optional configuration name from the model file. If not specified, defaults to `nil`, the "Default" configuration. Note that if you have multiple configurations, you will need to specify a different `fileName` explicitly for each of them.
|
||||
- parameter mappingModelBundles: a list of `NSBundle`s from which to search mapping models for migration
|
||||
- parameter localStorageOptions: When the `CSSQLiteStore` is passed to the `CSDataStack`'s `addStorage()` methods, tells the `CSDataStack` how to setup the persistent store. Defaults to `.None`.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(fileName: String, configuration: String?, mappingModelBundles: [NSBundle]?, localStorageOptions: CSLocalStorageOptions) {
|
||||
|
||||
self.init(
|
||||
SQLiteStore(
|
||||
fileName: fileName,
|
||||
configuration: configuration,
|
||||
mappingModelBundles: mappingModelBundles ?? NSBundle.allBundles(),
|
||||
localStorageOptions: LocalStorageOptions(rawValue: localStorageOptions.rawValue)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes an `CSSQLiteStore` with an all-default settings: a `fileURL` pointing to a "<Application name>.sqlite" file in the "Application Support/<bundle id>" directory (or the "Caches/<bundle id>" directory on tvOS), a `nil` `configuration` pertaining to the "Default" configuration, a `mappingModelBundles` set to search all `NSBundle`s, and `localStorageOptions` set to `.AllowProgresiveMigration`.
|
||||
- Warning: The default SQLite file location for the `CSLegacySQLiteStore` and `CSSQLiteStore` are different. If the app was depending on CoreStore's default directories prior to 2.0.0, make sure to use `CSLegacySQLiteStore` instead of `CSSQLiteStore`.
|
||||
*/
|
||||
@objc
|
||||
public convenience override init() {
|
||||
|
||||
self.init(SQLiteStore())
|
||||
}
|
||||
|
||||
|
||||
// MAKR: CSLocalStorage
|
||||
|
||||
/**
|
||||
The `NSURL` that points to the SQLite file
|
||||
*/
|
||||
@objc
|
||||
public var fileURL: NSURL {
|
||||
|
||||
return self.swift.fileURL
|
||||
}
|
||||
|
||||
/**
|
||||
The `NSBundle`s from which to search mapping models for migrations
|
||||
*/
|
||||
@objc
|
||||
public var mappingModelBundles: [NSBundle] {
|
||||
|
||||
return self.swift.mappingModelBundles
|
||||
}
|
||||
|
||||
/**
|
||||
Options that tell the `CSDataStack` how to setup the persistent store
|
||||
*/
|
||||
@objc
|
||||
public var localStorageOptions: CSLocalStorageOptions {
|
||||
|
||||
// TODO: allow options
|
||||
return CSLocalStorageOptions(rawValue: self.swift.localStorageOptions.rawValue) ?? .None
|
||||
}
|
||||
|
||||
|
||||
// MARK: CSStorageInterface
|
||||
|
||||
/**
|
||||
The string identifier for the `NSPersistentStore`'s `type` property. For `CSSQLiteStore`s, this is always set to `NSSQLiteStoreType`.
|
||||
*/
|
||||
@objc
|
||||
public static let storeType = NSSQLiteStoreType
|
||||
|
||||
/**
|
||||
The configuration name in the model file
|
||||
*/
|
||||
public var configuration: String? {
|
||||
|
||||
return self.swift.configuration
|
||||
}
|
||||
|
||||
/**
|
||||
The options dictionary for the `NSPersistentStore`. For `CSSQLiteStore`s, this is always set to
|
||||
```
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
```
|
||||
*/
|
||||
@objc
|
||||
public var storeOptions: [String: AnyObject]? {
|
||||
|
||||
return self.swift.storeOptions
|
||||
}
|
||||
|
||||
/**
|
||||
Called by the `CSDataStack` to perform actual deletion of the store file from disk. Do not call directly! The `sourceModel` argument is a hint for the existing store's model version. For `CSSQLiteStore`, this converts the database's WAL journaling mode to DELETE before deleting the file.
|
||||
*/
|
||||
@objc
|
||||
public func eraseStorageAndWait(soureModel soureModel: NSManagedObjectModel) throws {
|
||||
|
||||
try self.swift.eraseStorageAndWait(soureModel: soureModel)
|
||||
}
|
||||
|
||||
|
||||
// MARK: NSObject
|
||||
|
||||
98
Sources/ObjectiveC/CSStorageInterface.swift
Normal file
98
Sources/ObjectiveC/CSStorageInterface.swift
Normal file
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// CSStorageInterface.swift
|
||||
// CoreStore
|
||||
//
|
||||
// Created by John Rommel Estropia on 2016/03/18.
|
||||
// Copyright © 2016 John Rommel Estropia. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
/**
|
||||
The `CSStorageInterface` serves as the Objective-C bridging type for `StorageInterface`.
|
||||
*/
|
||||
@objc
|
||||
public protocol CSStorageInterface {
|
||||
|
||||
/**
|
||||
The string identifier for the `NSPersistentStore`'s `type` property. This is the same string CoreStore will use to create the `NSPersistentStore` from the `NSPersistentStoreCoordinator`'s `addPersistentStoreWithType(...)` method.
|
||||
*/
|
||||
@objc
|
||||
static var storeType: String { get }
|
||||
|
||||
/**
|
||||
The configuration name in the model file
|
||||
*/
|
||||
@objc
|
||||
var configuration: String? { get }
|
||||
|
||||
/**
|
||||
The options dictionary for the `NSPersistentStore`
|
||||
*/
|
||||
@objc
|
||||
var storeOptions: [String: AnyObject]? { get }
|
||||
}
|
||||
|
||||
|
||||
// MARK: - CSLocalStorageOptions
|
||||
|
||||
/**
|
||||
The `CSLocalStorageOptions` provides settings that tells the `CSDataStack` how to setup the persistent store for `CSLocalStorage` implementers.
|
||||
*/
|
||||
@objc
|
||||
public enum CSLocalStorageOptions: Int {
|
||||
|
||||
/**
|
||||
Tells the `DataStack` that the store should not be migrated or recreated, and should simply fail on model mismatch
|
||||
*/
|
||||
case None = 0
|
||||
|
||||
/**
|
||||
Tells the `DataStack` to delete and recreate the store on model mismatch, otherwise exceptions will be thrown on failure instead
|
||||
*/
|
||||
case RecreateStoreOnModelMismatch = 1
|
||||
|
||||
/**
|
||||
Tells the `DataStack` to prevent progressive migrations for the store
|
||||
*/
|
||||
case PreventProgressiveMigration = 2
|
||||
|
||||
/**
|
||||
Tells the `DataStack` to allow lightweight migration for the store when added synchronously
|
||||
*/
|
||||
case AllowSynchronousLightweightMigration = 4
|
||||
}
|
||||
|
||||
|
||||
// MARK: - CSLocalStorage
|
||||
|
||||
/**
|
||||
The `CSLocalStorage` serves as the Objective-C bridging type for `LocalStorage`.
|
||||
*/
|
||||
@objc
|
||||
public protocol CSLocalStorage: CSStorageInterface {
|
||||
|
||||
/**
|
||||
The `NSURL` that points to the store file
|
||||
*/
|
||||
@objc
|
||||
var fileURL: NSURL { get }
|
||||
|
||||
/**
|
||||
The `NSBundle`s from which to search mapping models for migrations
|
||||
*/
|
||||
@objc
|
||||
var mappingModelBundles: [NSBundle] { get }
|
||||
|
||||
/**
|
||||
Options that tell the `DataStack` how to setup the persistent store
|
||||
*/
|
||||
@objc
|
||||
var localStorageOptions: CSLocalStorageOptions { get }
|
||||
|
||||
/**
|
||||
Called by the `CSDataStack` to perform actual deletion of the store file from disk. Do not call directly! The `sourceModel` argument is a hint for the existing store's model version. Implementers can use the `sourceModel` to perform necessary store operations. (SQLite stores for example, can convert WAL journaling mode to DELETE before deleting)
|
||||
*/
|
||||
@objc
|
||||
func eraseStorageAndWait(soureModel soureModel: NSManagedObjectModel) throws
|
||||
}
|
||||
@@ -36,10 +36,10 @@ public protocol CoreStoreBridge: class, AnyObject {
|
||||
|
||||
public protocol CoreStoreBridgeable: _ObjectiveCBridgeable {
|
||||
|
||||
associatedtype NativeType: CoreStoreBridge
|
||||
associatedtype ObjCType: CoreStoreBridge
|
||||
}
|
||||
|
||||
public extension CoreStoreBridgeable where NativeType.SwiftType == Self {
|
||||
public extension CoreStoreBridgeable where Self == ObjCType.SwiftType {
|
||||
|
||||
static func _isBridgedToObjectiveC() -> Bool {
|
||||
|
||||
@@ -48,26 +48,26 @@ public extension CoreStoreBridgeable where NativeType.SwiftType == Self {
|
||||
|
||||
static func _getObjectiveCType() -> Any.Type {
|
||||
|
||||
return NativeType.self
|
||||
return ObjCType.self
|
||||
}
|
||||
|
||||
func _bridgeToObjectiveC() -> NativeType {
|
||||
func _bridgeToObjectiveC() -> ObjCType {
|
||||
|
||||
return NativeType(self)
|
||||
return ObjCType(self)
|
||||
}
|
||||
|
||||
static func _forceBridgeFromObjectiveC(source: NativeType, inout result: Self?) {
|
||||
static func _forceBridgeFromObjectiveC(source: ObjCType, inout result: ObjCType.SwiftType?) {
|
||||
|
||||
result = source.swift
|
||||
}
|
||||
|
||||
static func _conditionallyBridgeFromObjectiveC(source: NativeType, inout result: Self?) -> Bool {
|
||||
static func _conditionallyBridgeFromObjectiveC(source: ObjCType, inout result: ObjCType.SwiftType?) -> Bool {
|
||||
|
||||
self._forceBridgeFromObjectiveC(source, result: &result)
|
||||
result = source.swift
|
||||
return true
|
||||
}
|
||||
|
||||
var objc: NativeType {
|
||||
var objc: ObjCType {
|
||||
|
||||
return self._bridgeToObjectiveC()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user