This commit is contained in:
John Rommel Estropia
2016-07-21 02:45:42 +09:00
parent 267c21063a
commit a638620858
85 changed files with 1621 additions and 1819 deletions

View File

@@ -41,15 +41,15 @@ public extension CoreStore {
InMemoryStore.self,
completion: { result in
switch result {
case .Success(let storage): // ...
case .Failure(let error): // ...
case .success(let storage): // ...
case .failure(let error): // ...
}
}
)
```
- parameter storeType: the storage type
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.Success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
*/
public static func addStorage<T: StorageInterface where T: DefaultInitializableStore>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) {
@@ -63,15 +63,15 @@ public extension CoreStore {
InMemoryStore(configuration: "Config1"),
completion: { result in
switch result {
case .Success(let storage): // ...
case .Failure(let error): // ...
case .success(let storage): // ...
case .failure(let error): // ...
}
}
)
```
- parameter storage: the storage
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.Success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
*/
public static func addStorage<T: StorageInterface>(_ storage: T, completion: (SetupResult<T>) -> Void) {
@@ -85,15 +85,15 @@ public extension CoreStore {
SQLiteStore.self,
completion: { result in
switch result {
case .Success(let storage): // ...
case .Failure(let error): // ...
case .success(let storage): // ...
case .failure(let error): // ...
}
}
)
```
- parameter storeType: the local storage type
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.Success` may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
- returns: an `NSProgress` instance if a migration has started, or `nil` if either no migrations are required or if a failure occured.
*/
public static func addStorage<T: LocalStorage where T: DefaultInitializableStore>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) -> Progress? {
@@ -108,15 +108,15 @@ public extension CoreStore {
SQLiteStore(fileName: "core_data.sqlite", configuration: "Config1"),
completion: { result in
switch result {
case .Success(let storage): // ...
case .Failure(let error): // ...
case .success(let storage): // ...
case .failure(let error): // ...
}
}
)
```
- parameter storage: the local storage
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.Success` may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
- returns: an `NSProgress` instance if a migration has started, or `nil` if either no migrations are required or if a failure occured.
*/
public static func addStorage<T: LocalStorage>(_ storage: T, completion: (SetupResult<T>) -> Void) -> Progress? {
@@ -142,15 +142,15 @@ public extension CoreStore {
storage,
completion: { result in
switch result {
case .Success(let storage): // ...
case .Failure(let error): // ...
case .success(let storage): // ...
case .failure(let error): // ...
}
}
)
```
- parameter storage: the cloud storage
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `CloudStorage` associated to the `SetupResult.Success` may not always be the same instance as the parameter argument if a previous `CloudStorage` was already added at the same URL and with the same configuration.
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `CloudStorage` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `CloudStorage` was already added at the same URL and with the same configuration.
*/
public static func addStorage<T: CloudStorage>(_ storage: T, completion: (SetupResult<T>) -> Void) {
@@ -161,7 +161,7 @@ public extension CoreStore {
Migrates a local storage to match the `defaultStack`'s managed object model version. This method does NOT add the migrated store to the data stack.
- parameter storage: the local storage
- parameter completion: the closure to be executed on the main queue when the migration completes, either due to success or failure. The closure's `MigrationResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a `.Failure` result if an error occurs asynchronously.
- parameter completion: the closure to be executed on the main queue when the migration completes, either due to success or failure. The closure's `MigrationResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a `.failure` result if an error occurs asynchronously.
- throws: a `CoreStoreError` value indicating the failure
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
*/
@@ -177,7 +177,6 @@ public extension CoreStore {
- throws: a `CoreStoreError` value indicating the failure
- returns: a `MigrationType` array indicating the migration steps required for the store, or an empty array if the file does not exist yet. Otherwise, an error is thrown if either inspection of the store failed, or if no mapping model was found/inferred.
*/
@warn_unused_result
public static func requiredMigrationsForStorage<T: LocalStorage>(_ storage: T) throws -> [MigrationType] {
return try self.defaultStack.requiredMigrationsForStorage(storage)

View File

@@ -41,15 +41,15 @@ public extension DataStack {
InMemoryStore.self,
completion: { result in
switch result {
case .Success(let storage): // ...
case .Failure(let error): // ...
case .success(let storage): // ...
case .failure(let error): // ...
}
}
)
```
- parameter storeType: the storage type
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.Success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
*/
public func addStorage<T: StorageInterface where T: DefaultInitializableStore>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) {
@@ -63,15 +63,15 @@ public extension DataStack {
InMemoryStore(configuration: "Config1"),
completion: { result in
switch result {
case .Success(let storage): // ...
case .Failure(let error): // ...
case .success(let storage): // ...
case .failure(let error): // ...
}
}
)
```
- parameter storage: the storage
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.Success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
*/
public func addStorage<T: StorageInterface>(_ storage: T, completion: (SetupResult<T>) -> Void) {
@@ -88,7 +88,7 @@ public extension DataStack {
do {
try self.createPersistentStoreFromStorage(
_ = try self.createPersistentStoreFromStorage(
storage,
finalURL: nil,
finalStoreOptions: storage.storeOptions
@@ -121,15 +121,15 @@ public extension DataStack {
SQLiteStore.self,
completion: { result in
switch result {
case .Success(let storage): // ...
case .Failure(let error): // ...
case .success(let storage): // ...
case .failure(let error): // ...
}
}
)
```
- parameter storeType: the local storage type
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.Success` may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
- returns: an `NSProgress` instance if a migration has started, or `nil` if either no migrations are required or if a failure occured.
*/
public func addStorage<T: LocalStorage where T: DefaultInitializableStore>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) -> Progress? {
@@ -144,15 +144,15 @@ public extension DataStack {
SQLiteStore(fileName: "core_data.sqlite", configuration: "Config1"),
completion: { result in
switch result {
case .Success(let storage): // ...
case .Failure(let error): // ...
case .success(let storage): // ...
case .failure(let error): // ...
}
}
)
```
- parameter storage: the local storage
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.Success` may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
- returns: an `NSProgress` instance if a migration has started, or `nil` if either no migrations are required or if a failure occured.
*/
public func addStorage<T: LocalStorage>(_ storage: T, completion: (SetupResult<T>) -> Void) -> Progress? {
@@ -310,15 +310,15 @@ public extension DataStack {
storage,
completion: { result in
switch result {
case .Success(let storage): // ...
case .Failure(let error): // ...
case .success(let storage): // ...
case .failure(let error): // ...
}
}
)
```
- parameter storage: the cloud storage
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `CloudStorage` associated to the `SetupResult.Success` may not always be the same instance as the parameter argument if a previous `CloudStorage` was already added at the same URL and with the same configuration.
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `CloudStorage` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `CloudStorage` was already added at the same URL and with the same configuration.
*/
public func addStorage<T: CloudStorage>(_ storage: T, completion: (SetupResult<T>) -> Void) {
@@ -421,7 +421,7 @@ public extension DataStack {
let storeError = CoreStoreError(error)
CoreStore.log(
storeError,
"Failed to load \(cs_typeName(NSPersistentStore)) metadata."
"Failed to load \(cs_typeName(NSPersistentStore.self)) metadata."
)
GCDQueue.main.async {
@@ -481,7 +481,6 @@ public extension DataStack {
- throws: a `CoreStoreError` value indicating the failure
- returns: a `MigrationType` array indicating the migration steps required for the store, or an empty array if the file does not exist yet. Otherwise, an error is thrown if either inspection of the store failed, or if no mapping model was found/inferred.
*/
@warn_unused_result
public func requiredMigrationsForStorage<T: LocalStorage>(_ storage: T) throws -> [MigrationType] {
return try self.coordinator.performSynchronously {
@@ -614,7 +613,7 @@ public extension DataStack {
return
}
cs_autoreleasepool {
autoreleasepool {
do {
@@ -644,16 +643,7 @@ public extension DataStack {
}
let migrationOperation = BlockOperation()
#if USE_FRAMEWORKS
migrationOperation.qualityOfService = .utility
#else
if #available(iOS 8.0, *) {
migrationOperation.qualityOfService = .utility
}
#endif
migrationOperation.qualityOfService = .utility
operations.forEach { migrationOperation.addDependency($0) }
migrationOperation.addExecutionBlock { () -> Void in

View File

@@ -49,9 +49,9 @@ import Foundation
// ...
let result = transaction.commit()
switch result {
case .Success(let hasChanges):
case .success(let hasChanges):
// hasChanges indicates if there were changes or not
case .Failure(let error):
case .failure(let error):
// error is a CoreStoreError enum value
}
}
@@ -60,12 +60,12 @@ import Foundation
public enum MigrationResult: Boolean, Hashable {
/**
`MigrationResult.Success` indicates either the migration succeeded, or there were no migrations needed. The associated value is an array of `MigrationType`s reflecting the migration steps completed.
`MigrationResult.success` indicates either the migration succeeded, or there were no migrations needed. The associated value is an array of `MigrationType`s reflecting the migration steps completed.
*/
case success([MigrationType])
/**
`SaveResult.Failure` indicates that the migration failed. The associated object for this value is the a `CoreStoreError` enum value.
`SaveResult.failure` indicates that the migration failed. The associated object for this value is the a `CoreStoreError` enum value.
*/
case failure(CoreStoreError)
@@ -119,7 +119,6 @@ public enum MigrationResult: Boolean, Hashable {
// MARK: - SetupResult: Equatable
@warn_unused_result
public func == (lhs: MigrationResult, rhs: MigrationResult) -> Bool {
switch (lhs, rhs) {

View File

@@ -144,7 +144,6 @@ public enum MigrationType: Boolean, Hashable {
// MARK: - MigrationType: Equatable
@warn_unused_result
public func == (lhs: MigrationType, rhs: MigrationType) -> Bool {
switch (lhs, rhs) {

View File

@@ -51,9 +51,9 @@ import CoreData
SQLiteStore(),
completion: { (result: SetupResult) -> Void in
switch result {
case .Success(let storage):
case .success(let storage):
// storage is the related StorageInterface instance
case .Failure(let error):
case .failure(let error):
// error is the CoreStoreError enum value for the failure
}
}
@@ -63,12 +63,12 @@ import CoreData
public enum SetupResult<T: StorageInterface>: Boolean, Hashable {
/**
`SetupResult.Success` indicates that the storage setup succeeded. The associated object for this `enum` value is the related `StorageInterface` instance.
`SetupResult.success` indicates that the storage setup succeeded. The associated object for this `enum` value is the related `StorageInterface` instance.
*/
case success(T)
/**
`SetupResult.Failure` indicates that the storage setup failed. The associated object for this value is the related `CoreStoreError` enum value.
`SetupResult.failure` indicates that the storage setup failed. The associated object for this value is the related `CoreStoreError` enum value.
*/
case failure(CoreStoreError)
@@ -121,7 +121,6 @@ public enum SetupResult<T: StorageInterface>: Boolean, Hashable {
// MARK: - SetupResult: Equatable
@warn_unused_result
public func == <T: StorageInterface, U: StorageInterface>(lhs: SetupResult<T>, rhs: SetupResult<U>) -> Bool {
switch (lhs, rhs) {
@@ -147,12 +146,12 @@ public func == <T: StorageInterface, U: StorageInterface>(lhs: SetupResult<T>, r
public enum PersistentStoreResult: Boolean {
/**
Deprecated. Replaced by `SetupResult.Success` when using the new `addStorage(_:completion:)` method variants.
Deprecated. Replaced by `SetupResult.success` when using the new `addStorage(_:completion:)` method variants.
*/
case success(NSPersistentStore)
/**
Deprecated. Replaced by `SetupResult.Failure` when using the new `addStorage(_:completion:)` method variants.
Deprecated. Replaced by `SetupResult.failure` when using the new `addStorage(_:completion:)` method variants.
*/
case failure(NSError)