mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-18 06:59:42 +02:00
documentation updates
This commit is contained in:
@@ -127,15 +127,19 @@ public extension CoreStore {
|
|||||||
/**
|
/**
|
||||||
Asynchronously adds a `CloudStorage` to the `defaultStack`. Migrations are also initiated by default.
|
Asynchronously adds a `CloudStorage` to the `defaultStack`. Migrations are also initiated by default.
|
||||||
```
|
```
|
||||||
|
guard let storage = ICloudStore(
|
||||||
|
ubiquitousContentName: "MyAppCloudData",
|
||||||
|
ubiquitousContentTransactionLogsSubdirectory: "logs/config1",
|
||||||
|
ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername",
|
||||||
|
ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0",
|
||||||
|
configuration: "Config1",
|
||||||
|
cloudStorageOptions: .RecreateLocalStoreOnModelMismatch
|
||||||
|
) else {
|
||||||
|
// iCloud is not available on the device
|
||||||
|
return
|
||||||
|
}
|
||||||
let migrationProgress = dataStack.addStorage(
|
let migrationProgress = dataStack.addStorage(
|
||||||
ICloudStore(
|
storage,
|
||||||
ubiquitousContentName: "MyAppCloudData",
|
|
||||||
ubiquitousContentTransactionLogsSubdirectory: "logs/config1",
|
|
||||||
ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername",
|
|
||||||
ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0",
|
|
||||||
configuration: "Config1",
|
|
||||||
cloudStorageOptions: .AllowSynchronousLightweightMigration
|
|
||||||
),
|
|
||||||
completion: { result in
|
completion: { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .Success(let storage): // ...
|
case .Success(let storage): // ...
|
||||||
|
|||||||
@@ -295,15 +295,19 @@ public extension DataStack {
|
|||||||
/**
|
/**
|
||||||
Asynchronously adds a `CloudStorage` to the stack. Migrations are also initiated by default.
|
Asynchronously adds a `CloudStorage` to the stack. Migrations are also initiated by default.
|
||||||
```
|
```
|
||||||
|
guard let storage = ICloudStore(
|
||||||
|
ubiquitousContentName: "MyAppCloudData",
|
||||||
|
ubiquitousContentTransactionLogsSubdirectory: "logs/config1",
|
||||||
|
ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername",
|
||||||
|
ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0",
|
||||||
|
configuration: "Config1",
|
||||||
|
cloudStorageOptions: .RecreateLocalStoreOnModelMismatch
|
||||||
|
) else {
|
||||||
|
// iCloud is not available on the device
|
||||||
|
return
|
||||||
|
}
|
||||||
dataStack.addStorage(
|
dataStack.addStorage(
|
||||||
ICloudStore(
|
storage,
|
||||||
ubiquitousContentName: "MyAppCloudData",
|
|
||||||
ubiquitousContentTransactionLogsSubdirectory: "logs/config1",
|
|
||||||
ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername",
|
|
||||||
ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0",
|
|
||||||
configuration: "Config1",
|
|
||||||
cloudStorageOptions: .AllowSynchronousLightweightMigration
|
|
||||||
),
|
|
||||||
completion: { result in
|
completion: { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .Success(let storage): // ...
|
case .Success(let storage): // ...
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// CoreStoreObjectiveCType.swift
|
// CoreStoreBridge.swift
|
||||||
// CoreStore
|
// CoreStore
|
||||||
//
|
//
|
||||||
// Copyright © 2016 John Rommel Estropia
|
// Copyright © 2016 John Rommel Estropia
|
||||||
|
|||||||
@@ -134,16 +134,18 @@ public extension CoreStore {
|
|||||||
/**
|
/**
|
||||||
Adds a `CloudStorage` to the `defaultStack` and blocks until completion.
|
Adds a `CloudStorage` to the `defaultStack` and blocks until completion.
|
||||||
```
|
```
|
||||||
try CoreStore.addStorageAndWait(
|
guard let storage = ICloudStore(
|
||||||
ICloudStore(
|
ubiquitousContentName: "MyAppCloudData",
|
||||||
ubiquitousContentName: "MyAppCloudData",
|
ubiquitousContentTransactionLogsSubdirectory: "logs/config1",
|
||||||
ubiquitousContentTransactionLogsSubdirectory: "logs/config1",
|
ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername",
|
||||||
ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername",
|
ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0",
|
||||||
ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0",
|
configuration: "Config1",
|
||||||
configuration: "Config1",
|
cloudStorageOptions: .RecreateLocalStoreOnModelMismatch
|
||||||
cloudStorageOptions: .AllowSynchronousLightweightMigration
|
) else {
|
||||||
)
|
// iCloud is not available on the device
|
||||||
)
|
return
|
||||||
|
}
|
||||||
|
try CoreStore.addStorageAndWait(storage)
|
||||||
```
|
```
|
||||||
|
|
||||||
- parameter storage: the local storage
|
- parameter storage: the local storage
|
||||||
|
|||||||
@@ -288,16 +288,18 @@ public final class DataStack {
|
|||||||
/**
|
/**
|
||||||
Adds a `CloudStorage` to the stack and blocks until completion.
|
Adds a `CloudStorage` to the stack and blocks until completion.
|
||||||
```
|
```
|
||||||
try dataStack.addStorageAndWait(
|
guard let storage = ICloudStore(
|
||||||
ICloudStore(
|
ubiquitousContentName: "MyAppCloudData",
|
||||||
ubiquitousContentName: "MyAppCloudData",
|
ubiquitousContentTransactionLogsSubdirectory: "logs/config1",
|
||||||
ubiquitousContentTransactionLogsSubdirectory: "logs/config1",
|
ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername",
|
||||||
ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername",
|
ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0",
|
||||||
ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0",
|
configuration: "Config1",
|
||||||
configuration: "Config1",
|
cloudStorageOptions: .RecreateLocalStoreOnModelMismatch
|
||||||
cloudStorageOptions: .AllowSynchronousLightweightMigration
|
) else {
|
||||||
)
|
// iCloud is not available on the device
|
||||||
)
|
return
|
||||||
|
}
|
||||||
|
try dataStack.addStorageAndWait(storage)
|
||||||
```
|
```
|
||||||
|
|
||||||
- parameter storage: the local storage
|
- parameter storage: the local storage
|
||||||
|
|||||||
@@ -39,15 +39,19 @@ public class ICloudStore: CloudStorage {
|
|||||||
/**
|
/**
|
||||||
Initializes an iCloud store interface from the given ubiquitous store information. Returns `nil` if the container could not be located or if iCloud storage is unavailable for the current user or device
|
Initializes an iCloud store interface from the given ubiquitous store information. Returns `nil` if the container could not be located or if iCloud storage is unavailable for the current user or device
|
||||||
```
|
```
|
||||||
try CoreStore.addStorage(
|
guard let storage = ICloudStore(
|
||||||
ICloudStore(
|
ubiquitousContentName: "MyAppCloudData",
|
||||||
ubiquitousContentName: "MyAppCloudData",
|
ubiquitousContentTransactionLogsSubdirectory: "logs/config1",
|
||||||
ubiquitousContentTransactionLogsSubdirectory: "logs/config1",
|
ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername",
|
||||||
ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername",
|
ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0",
|
||||||
ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0",
|
configuration: "Config1",
|
||||||
configuration: "Config1",
|
cloudStorageOptions: .RecreateLocalStoreOnModelMismatch
|
||||||
cloudStorageOptions: .AllowSynchronousLightweightMigration
|
) else {
|
||||||
)
|
// iCloud is not available on the device
|
||||||
|
return
|
||||||
|
}
|
||||||
|
CoreStore.addStorage(
|
||||||
|
storage,
|
||||||
completion: { result in
|
completion: { result in
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
|
|||||||
|
|
||||||
- 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 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 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 mappingModelBundles: a list of `NSBundle`s from which to search mapping models (*.xcmappingmodel) for migration.
|
||||||
- parameter localStorageOptions: When the `SQLiteStore` is passed to the `DataStack`'s `addStorage()` methods, tells the `DataStack` how to setup the persistent store. Defaults to `.None`.
|
- parameter localStorageOptions: When the `SQLiteStore` is passed to the `DataStack`'s `addStorage()` methods, tells the `DataStack` how to setup the persistent store. Defaults to `.None`.
|
||||||
*/
|
*/
|
||||||
public init(fileURL: NSURL, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles(), localStorageOptions: LocalStorageOptions = nil) {
|
public init(fileURL: NSURL, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles(), localStorageOptions: LocalStorageOptions = nil) {
|
||||||
@@ -57,7 +57,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
|
|||||||
- Warning: The default SQLite file location for the `LegacySQLiteStore` and `SQLiteStore` are different. If the app was depending on CoreStore's default directories prior to 2.0.0, make sure to use `LegacySQLiteStore` instead of `SQLiteStore`.
|
- Warning: The default SQLite file location for the `LegacySQLiteStore` and `SQLiteStore` are different. If the app was depending on CoreStore's default directories prior to 2.0.0, make sure to use `LegacySQLiteStore` instead of `SQLiteStore`.
|
||||||
- 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 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 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 mappingModelBundles: a list of `NSBundle`s from which to search mapping models (*.xcmappingmodel) for migration
|
||||||
- parameter localStorageOptions: When the `SQLiteStore` is passed to the `DataStack`'s `addStorage()` methods, tells the `DataStack` how to setup the persistent store. Defaults to `.None`.
|
- parameter localStorageOptions: When the `SQLiteStore` is passed to the `DataStack`'s `addStorage()` methods, tells the `DataStack` how to setup the persistent store. Defaults to `.None`.
|
||||||
*/
|
*/
|
||||||
public init(fileName: String, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles(), localStorageOptions: LocalStorageOptions = nil) {
|
public init(fileName: String, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles(), localStorageOptions: LocalStorageOptions = nil) {
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public protocol LocalStorage: StorageInterface {
|
|||||||
var fileURL: NSURL { get }
|
var fileURL: NSURL { get }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The `NSBundle`s from which to search mapping models for migrations
|
The `NSBundle`s from which to search mapping models (*.xcmappingmodel) for migrations
|
||||||
*/
|
*/
|
||||||
var mappingModelBundles: [NSBundle] { get }
|
var mappingModelBundles: [NSBundle] { get }
|
||||||
|
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
|||||||
self.context.reset()
|
self.context.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(*, deprecated=1.5.2, renamed="commitAndWait")
|
@available(*, deprecated=1.5.2, obsoleted=2.0.0, renamed="commitAndWait")
|
||||||
public func commit() {
|
public func commit() {
|
||||||
|
|
||||||
self.commitAndWait()
|
self.commitAndWait()
|
||||||
|
|||||||
Reference in New Issue
Block a user