From 1af675e8b7206a6f1e0bffe4487dd1218df655e2 Mon Sep 17 00:00:00 2001 From: John Rommel Estropia Date: Sat, 20 Feb 2016 12:05:01 +0900 Subject: [PATCH] tidy up --- .../Concrete Clauses/From.swift | 112 ++++++++++++++++++ README.md | 19 ++- 2 files changed, 119 insertions(+), 12 deletions(-) diff --git a/CoreStore/Fetching and Querying/Concrete Clauses/From.swift b/CoreStore/Fetching and Querying/Concrete Clauses/From.swift index 0a1ff8f..aa17f78 100644 --- a/CoreStore/Fetching and Querying/Concrete Clauses/From.swift +++ b/CoreStore/Fetching and Querying/Concrete Clauses/From.swift @@ -106,81 +106,193 @@ public struct From { self.init(entityClass: T.self, configurations: configurations) } + /** + Initializes a `From` clause with the specified configurations. + Sample Usage: + ``` + let people = transaction.fetchAll(From(MyPersonEntity.self, nil, "Configuration1")) + ``` + - parameter entity: the associated `NSManagedObject` type + - parameter configuration: the `NSPersistentStore` configuration name to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject`'s entity type. Set to `nil` to use the default configuration. + - parameter otherConfigurations: an optional list of other configuration names to associate objects from (see `configuration` parameter) + */ public init(_ entity: T.Type, _ configuration: String?, _ otherConfigurations: String?...) { self.init(entityClass: entity, configurations: [configuration] + otherConfigurations) } + /** + Initializes a `From` clause with the specified configurations. + Sample Usage: + ``` + let people = transaction.fetchAll(From(MyPersonEntity.self, ["Configuration1", "Configuration1"])) + ``` + - parameter entity: the associated `NSManagedObject` type + - parameter configurations: a list of `NSPersistentStore` configuration names to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject`'s entity type. Set to `nil` to use the default configuration. + */ public init(_ entity: T.Type, _ configurations: [String?]) { self.init(entityClass: entity, configurations: configurations) } + /** + Initializes a `From` clause with the specified configurations. + Sample Usage: + ``` + let people = transaction.fetchAll(From(MyPersonEntity.self, nil, "Configuration1")) + ``` + - parameter entity: the associated `NSManagedObject` entity class + - parameter configuration: the `NSPersistentStore` configuration name to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject`'s entity type. Set to `nil` to use the default configuration. + - parameter otherConfigurations: an optional list of other configuration names to associate objects from (see `configuration` parameter) + */ public init(_ entityClass: AnyClass, _ configuration: String?, _ otherConfigurations: String?...) { self.init(entityClass: entityClass, configurations: [configuration] + otherConfigurations) } + /** + Initializes a `From` clause with the specified configurations. + Sample Usage: + ``` + let people = transaction.fetchAll(From(MyPersonEntity.self, ["Configuration1", "Configuration1"])) + ``` + - parameter entity: the associated `NSManagedObject` entity class + - parameter configurations: a list of `NSPersistentStore` configuration names to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject`'s entity type. Set to `nil` to use the default configuration. + */ public init(_ entityClass: AnyClass, _ configurations: [String?]) { self.init(entityClass: entityClass, configurations: configurations) } + /** + Initializes a `From` clause with the specified store URLs. + + - parameter storeURL: the persistent store URL to associate objects from. + - parameter otherStoreURLs: an optional list of other persistent store URLs to associate objects from (see `storeURL` parameter) + */ public init(_ storeURL: NSURL, _ otherStoreURLs: NSURL...) { self.init(entityClass: T.self, storeURLs: [storeURL] + otherStoreURLs) } + /** + Initializes a `From` clause with the specified store URLs. + + - parameter storeURLs: the persistent store URLs to associate objects from. + */ public init(_ storeURLs: [NSURL]) { self.init(entityClass: T.self, storeURLs: storeURLs) } + /** + Initializes a `From` clause with the specified store URLs. + + - parameter entity: the associated `NSManagedObject` type + - parameter storeURL: the persistent store URL to associate objects from. + - parameter otherStoreURLs: an optional list of other persistent store URLs to associate objects from (see `storeURL` parameter) + */ public init(_ entity: T.Type, _ storeURL: NSURL, _ otherStoreURLs: NSURL...) { self.init(entityClass: entity, storeURLs: [storeURL] + otherStoreURLs) } + /** + Initializes a `From` clause with the specified store URLs. + + - parameter entity: the associated `NSManagedObject` type + - parameter storeURLs: the persistent store URLs to associate objects from. + */ public init(_ entity: T.Type, _ storeURLs: [NSURL]) { self.init(entityClass: entity, storeURLs: storeURLs) } + /** + Initializes a `From` clause with the specified store URLs. + + - parameter entity: the associated `NSManagedObject` entity class + - parameter storeURL: the persistent store URL to associate objects from. + - parameter otherStoreURLs: an optional list of other persistent store URLs to associate objects from (see `storeURL` parameter) + */ public init(_ entityClass: AnyClass, _ storeURL: NSURL, _ otherStoreURLs: NSURL...) { self.init(entityClass: entityClass, storeURLs: [storeURL] + otherStoreURLs) } + /** + Initializes a `From` clause with the specified store URLs. + + - parameter entity: the associated `NSManagedObject` entity class + - parameter storeURLs: the persistent store URLs to associate objects from. + */ public init(_ entityClass: AnyClass, _ storeURLs: [NSURL]) { self.init(entityClass: entityClass, storeURLs: storeURLs) } + /** + Initializes a `From` clause with the specified `NSPersistentStore`s. + + - parameter persistentStore: the `NSPersistentStore` to associate objects from. + - parameter otherPersistentStores: an optional list of other `NSPersistentStore`s to associate objects from (see `persistentStore` parameter) + */ public init(_ persistentStore: NSPersistentStore, _ otherPersistentStores: NSPersistentStore...) { self.init(entityClass: T.self, persistentStores: [persistentStore] + otherPersistentStores) } + /** + Initializes a `From` clause with the specified `NSPersistentStore`s. + + - parameter persistentStores: the `NSPersistentStore`s to associate objects from. + */ public init(_ persistentStores: [NSPersistentStore]) { self.init(entityClass: T.self, persistentStores: persistentStores) } + /** + Initializes a `From` clause with the specified `NSPersistentStore`s. + + - parameter entity: the associated `NSManagedObject` type + - parameter persistentStore: the `NSPersistentStore` to associate objects from. + - parameter otherPersistentStores: an optional list of other `NSPersistentStore`s to associate objects from (see `persistentStore` parameter) + */ public init(_ entity: T.Type, _ persistentStore: NSPersistentStore, _ otherPersistentStores: NSPersistentStore...) { self.init(entityClass: entity, persistentStores: [persistentStore] + otherPersistentStores) } + /** + Initializes a `From` clause with the specified `NSPersistentStore`s. + + - parameter entity: the associated `NSManagedObject` type + - parameter persistentStores: the `NSPersistentStore`s to associate objects from. + */ public init(_ entity: T.Type, _ persistentStores: [NSPersistentStore]) { self.init(entityClass: entity, persistentStores: persistentStores) } + /** + Initializes a `From` clause with the specified `NSPersistentStore`s. + + - parameter entity: the associated `NSManagedObject` entity class + - parameter persistentStore: the `NSPersistentStore` to associate objects from. + - parameter otherPersistentStores: an optional list of other `NSPersistentStore`s to associate objects from (see `persistentStore` parameter) + */ public init(_ entityClass: AnyClass, _ persistentStore: NSPersistentStore, _ otherPersistentStores: NSPersistentStore...) { self.init(entityClass: entityClass, persistentStores: [persistentStore] + otherPersistentStores) } + /** + Initializes a `From` clause with the specified `NSPersistentStore`s. + + - parameter entity: the associated `NSManagedObject` entity class + - parameter persistentStores: the `NSPersistentStore`s to associate objects from. + */ public init(_ entityClass: AnyClass, _ persistentStores: [NSPersistentStore]) { self.init(entityClass: entityClass, persistentStores: persistentStores) diff --git a/README.md b/README.md index 082c7d7..e5968bc 100644 --- a/README.md +++ b/README.md @@ -80,17 +80,12 @@ CoreStore.defaultStack = DataStack( Adding a store: ```swift -do { - try CoreStore.addSQLiteStore( - fileName: "MyStore.sqlite", - completion: { (result) -> Void in - // ... - } - ) -} -catch { - // ... -} +try CoreStore.addSQLiteStore( + fileName: "MyStore.sqlite", + completion: { (result) -> Void in + // ... + } +) ``` Starting transactions: @@ -1169,7 +1164,7 @@ let person2 = self.monitor[1, 2] # Installation - Requires: - iOS 8 SDK and above - - Swift 2.0 (Xcode 7 beta 6) + - Swift 2.1 (Xcode 7.2) - Dependencies: - [GCDKit](https://github.com/JohnEstropia/GCDKit)