comment documentations

This commit is contained in:
John Rommel Estropia
2016-04-03 19:47:25 +09:00
parent ab3095f078
commit dccc958ef1
54 changed files with 333 additions and 64 deletions

View File

@@ -47,8 +47,10 @@ public extension CoreStore {
}
)
```
- 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. This closure is NOT executed if an error is thrown, but will be executed with a `.Failure` result if an error occurs asynchronously. 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.
- throws: a `CoreStoreError` value indicating the failure
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
*/
public static func addStorage<T: StorageInterface where T: DefaultInitializableStore>(storeType: T.Type, completion: (SetupResult<T>) -> Void) throws -> NSProgress? {
@@ -69,8 +71,10 @@ public extension CoreStore {
}
)
```
- 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. 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
*/
public static func addStorage<T: StorageInterface>(storage: T, completion: (SetupResult<T>) -> Void) throws -> NSProgress? {
@@ -91,8 +95,10 @@ public extension CoreStore {
}
)
```
- 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. This closure is NOT executed if an error is thrown, but will be executed with a `.Failure` result if an error occurs asynchronously. 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.
- throws: a `CoreStoreError` value indicating the failure
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
*/
public static func addStorage<T: LocalStorage where T: DefaultInitializableStore>(storeType: T.Type, completion: (SetupResult<T>) -> Void) throws -> NSProgress? {
@@ -113,8 +119,10 @@ public extension CoreStore {
}
)
```
- 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. This closure is NOT executed if an error is thrown, but will be executed with a `.Failure` result if an error occurs asynchronously. 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.
- throws: a `CoreStoreError` value indicating the failure
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
*/
public static func addStorage<T: LocalStorage>(storage: T, completion: (SetupResult<T>) -> Void) throws -> NSProgress? {
@@ -127,6 +135,7 @@ public extension CoreStore {
- 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.
- throws: a `CoreStoreError` value indicating the failure
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
*/
public static func upgradeStorageIfNeeded<T: LocalStorage>(storage: T, completion: (MigrationResult) -> Void) throws -> NSProgress? {
@@ -138,6 +147,7 @@ public extension CoreStore {
Checks the migration steps required for the storage to match the `defaultStack`'s managed object model version.
- parameter storage: the local storage
- 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

View File

@@ -47,8 +47,10 @@ public extension DataStack {
}
)
```
- 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. This closure is NOT executed if an error is thrown, but will be executed with a `.Failure` result if an error occurs asynchronously. 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.
- throws: a `CoreStoreError` value indicating the failure
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
*/
public func addStorage<T: StorageInterface where T: DefaultInitializableStore>(storeType: T.Type, completion: (SetupResult<T>) -> Void) throws -> NSProgress? {
@@ -69,8 +71,10 @@ public extension DataStack {
}
)
```
- 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. 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
*/
public func addStorage<T: StorageInterface>(storage: T, completion: (SetupResult<T>) -> Void) throws -> NSProgress? {
@@ -130,8 +134,10 @@ public extension DataStack {
}
)
```
- 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. This closure is NOT executed if an error is thrown, but will be executed with a `.Failure` result if an error occurs asynchronously. 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.
- throws: a `CoreStoreError` value indicating the failure
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
*/
public func addStorage<T: LocalStorage where T: DefaultInitializableStore>(storeType: T.Type, completion: (SetupResult<T>) -> Void) throws -> NSProgress? {
@@ -152,8 +158,10 @@ public extension DataStack {
}
)
```
- 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. This closure is NOT executed if an error is thrown, but will be executed with a `.Failure` result if an error occurs asynchronously. 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.
- throws: a `CoreStoreError` value indicating the failure
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
*/
public func addStorage<T: LocalStorage>(storage: T, completion: (SetupResult<T>) -> Void) throws -> NSProgress? {
@@ -280,6 +288,7 @@ public extension DataStack {
- 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.
- throws: a `CoreStoreError` value indicating the failure
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
*/
public func upgradeStorageIfNeeded<T: LocalStorage>(storage: T, completion: (MigrationResult) -> Void) throws -> NSProgress? {
@@ -321,6 +330,7 @@ public extension DataStack {
Checks the migration steps required for the storage to match the `DataStack`'s managed object model version.
- parameter storage: the local storage
- 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

View File

@@ -62,6 +62,9 @@ import CoreData
*/
public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, DictionaryLiteralConvertible, ArrayLiteralConvertible {
/**
Initializes the `MigrationChain` with empty values, which instructs the `DataStack` to use the .xcdatamodel's current version as the final version, and to disable progressive migrations.
*/
public init() {
self.versionTree = [:]
@@ -70,6 +73,9 @@ public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, D
self.valid = true
}
/**
Initializes the `MigrationChain` with a single model version, which instructs the `DataStack` to use the the specified version as the final version, and to disable progressive migrations.
*/
public init(_ value: String) {
self.versionTree = [:]
@@ -78,6 +84,9 @@ public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, D
self.valid = true
}
/**
Initializes the `MigrationChain` with a linear order of versions, which becomes the order of the `DataStack`'s progressive migrations.
*/
public init<T: CollectionType where T.Generator.Element == String, T.Index: BidirectionalIndexType>(_ elements: T) {
CoreStore.assert(Set(elements).count == Array(elements).count, "\(typeName(MigrationChain))'s migration chain could not be created due to duplicate version strings.")
@@ -101,6 +110,9 @@ public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, D
self.valid = valid
}
/**
Initializes the `MigrationChain` with a version tree, which becomes the order of the `DataStack`'s progressive migrations.
*/
public init(_ elements: [(String, String)]) {
var valid = true
@@ -147,6 +159,9 @@ public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, D
self.valid = valid && Set(versionTree.keys).union(versionTree.values).filter { isVersionAmbiguous($0) }.count <= 0
}
/**
Initializes the `MigrationChain` with a version tree, which becomes the order of the `DataStack`'s progressive migrations.
*/
public init(_ dictionary: [String: String]) {
self.init(dictionary.map { $0 })