From b2a190ea3394e3de944a96fe9a2023aa1ea10f3b Mon Sep 17 00:00:00 2001 From: John Estropia Date: Thu, 9 Jul 2015 21:28:37 +0900 Subject: [PATCH] require explicit parameter for fileName when calling addSQLiteStore() and it's variants --- CoreStore/Migrating/DataStack+Migration.swift | 6 +++--- CoreStore/Setting Up/CoreStore+Setup.swift | 4 ++-- CoreStore/Setting Up/DataStack.swift | 2 +- .../FetchingAndQueryingDemoViewController.swift | 2 +- .../ListObserverDemoViewController.swift | 2 +- .../Loggers Demo/CustomLoggerViewController.swift | 4 ++-- .../MIgrations Demo/MigrationsDemoViewController.swift | 2 +- .../Stack Setup Demo/StackSetupDemoViewController.swift | 8 ++++---- .../TransactionsDemoViewController.swift | 2 +- CoreStoreTests/CoreStoreTests.swift | 4 ++-- README.md | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CoreStore/Migrating/DataStack+Migration.swift b/CoreStore/Migrating/DataStack+Migration.swift index 02fce91..c944cef 100644 --- a/CoreStore/Migrating/DataStack+Migration.swift +++ b/CoreStore/Migrating/DataStack+Migration.swift @@ -40,7 +40,7 @@ public extension DataStack { - parameter mappingModelBundles: an optional array of bundles to search mapping model files from. If not set, defaults to the `NSBundle.allBundles()`. :return: a `MigrationType` indicating the type of migration required for the store; or `nil` if either inspection of the store failed, or no mapping model was found/inferred. `MigrationType` acts as a `Bool` and evaluates to `false` if no migration is required, and `true` if either a lightweight or custom migration is needed. */ - public func needsMigrationForSQLiteStore(fileName: String, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles() as [NSBundle]) -> MigrationType? { + public func needsMigrationForSQLiteStore(fileName fileName: String, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles() as [NSBundle]) -> MigrationType? { return needsMigrationForSQLiteStore( fileURL: applicationSupportDirectory.URLByAppendingPathComponent( @@ -122,7 +122,7 @@ public extension DataStack { - parameter sourceBundles: an optional array of bundles to search mapping model files from. If not set, defaults to the `NSBundle.mainBundle()`. - parameter sourceBundles: an optional array of bundles to search mapping model files from. If not set, defaults to the `NSBundle.mainBundle()`. */ - public func upgradeSQLiteStoreIfNeeded(fileName: String, configuration: String? = nil, sourceBundles: [NSBundle]? = nil, completion: (MigrationResult) -> Void) -> MigrationType? { + public func upgradeSQLiteStoreIfNeeded(fileName fileName: String, configuration: String? = nil, sourceBundles: [NSBundle]? = nil, completion: (MigrationResult) -> Void) -> MigrationType? { return self.upgradeSQLiteStoreIfNeeded( fileURL: applicationSupportDirectory.URLByAppendingPathComponent( @@ -262,7 +262,7 @@ public extension DataStack { - 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 completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `PersistentStoreResult` argument indicates the result. */ - public func addSQLiteStore(fileName: String, configuration: String? = nil, sourceBundles: [NSBundle]? = nil, completion: (PersistentStoreResult) -> Void) { + public func addSQLiteStore(fileName fileName: String, configuration: String? = nil, sourceBundles: [NSBundle]? = nil, completion: (PersistentStoreResult) -> Void) { self.addSQLiteStore( fileURL: applicationSupportDirectory.URLByAppendingPathComponent( diff --git a/CoreStore/Setting Up/CoreStore+Setup.swift b/CoreStore/Setting Up/CoreStore+Setup.swift index 41a695d..f34981b 100644 --- a/CoreStore/Setting Up/CoreStore+Setup.swift +++ b/CoreStore/Setting Up/CoreStore+Setup.swift @@ -52,10 +52,10 @@ public extension CoreStore { - parameter resetStoreOnMigrationFailure: Set to true to delete the store on migration failure; or set to false to throw exceptions on failure instead. Typically should only be set to true when debugging, or if the persistent store can be recreated easily. If not specified, defaults to false - returns: a `PersistentStoreResult` indicating success or failure. */ - public static func addSQLiteStoreAndWait(fileName: String, configuration: String? = nil, automigrating: Bool = true, resetStoreOnMigrationFailure: Bool = false) -> PersistentStoreResult { + public static func addSQLiteStoreAndWait(fileName fileName: String, configuration: String? = nil, automigrating: Bool = true, resetStoreOnMigrationFailure: Bool = false) -> PersistentStoreResult { return self.defaultStack.addSQLiteStoreAndWait( - fileName, + fileName: fileName, configuration: configuration, automigrating: automigrating, resetStoreOnMigrationFailure: resetStoreOnMigrationFailure diff --git a/CoreStore/Setting Up/DataStack.swift b/CoreStore/Setting Up/DataStack.swift index 8703326..4f37815 100644 --- a/CoreStore/Setting Up/DataStack.swift +++ b/CoreStore/Setting Up/DataStack.swift @@ -136,7 +136,7 @@ public final class DataStack { - parameter resetStoreOnMigrationFailure: Set to true to delete the store on migration failure; or set to false to throw exceptions on failure instead. Typically should only be set to true when debugging, or if the persistent store can be recreated easily. If not specified, defaults to false - returns: a `PersistentStoreResult` indicating success or failure. */ - public func addSQLiteStoreAndWait(fileName: String, configuration: String? = nil, automigrating: Bool = true, resetStoreOnMigrationFailure: Bool = false) -> PersistentStoreResult { + public func addSQLiteStoreAndWait(fileName fileName: String, configuration: String? = nil, automigrating: Bool = true, resetStoreOnMigrationFailure: Bool = false) -> PersistentStoreResult { return self.addSQLiteStoreAndWait( fileURL: applicationSupportDirectory.URLByAppendingPathComponent( diff --git a/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift index 1428910..11e544e 100644 --- a/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift @@ -16,7 +16,7 @@ private struct Static { let dataStack = DataStack() dataStack.addSQLiteStoreAndWait( - "TimeZoneDemo.sqlite", + fileName: "TimeZoneDemo.sqlite", configuration: "FetchingAndQueryingDemo", resetStoreOnMigrationFailure: true ) diff --git a/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ListObserverDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ListObserverDemoViewController.swift index 616d75f..be2382b 100644 --- a/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ListObserverDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ListObserverDemoViewController.swift @@ -15,7 +15,7 @@ private struct Static { static let palettes: ListMonitor = { CoreStore.addSQLiteStoreAndWait( - "ColorsDemo.sqlite", + fileName: "ColorsDemo.sqlite", configuration: "ObservingDemo", resetStoreOnMigrationFailure: true ) diff --git a/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift b/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift index b87c436..c25417a 100644 --- a/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift @@ -30,7 +30,7 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger { super.viewDidLoad() - self.dataStack.addSQLiteStoreAndWait("emptyStore.sqlite") + self.dataStack.addSQLiteStoreAndWait(fileName: "emptyStore.sqlite") CoreStore.logger = self } @@ -109,7 +109,7 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger { } case .Some(1): - self.dataStack.addSQLiteStoreAndWait("emptyStore.sqlite", configuration: "invalidStore") + self.dataStack.addSQLiteStoreAndWait(fileName: "emptyStore.sqlite", configuration: "invalidStore") case .Some(2): self.dataStack.beginAsynchronous { (transaction) -> Void in diff --git a/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift index 98f32a0..92d4da5 100644 --- a/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift @@ -114,7 +114,7 @@ class MigrationsDemoViewController: UITableViewController { self.setEnabled(false) dataStack.addSQLiteStore( - "MigrationDemo.sqlite", + fileName: "MigrationDemo.sqlite", completion: { [weak self] (result) -> Void in guard let strongSelf = self else { diff --git a/CoreStoreDemo/CoreStoreDemo/Stack Setup Demo/StackSetupDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/Stack Setup Demo/StackSetupDemoViewController.swift index 8c1aeea..88a1681 100644 --- a/CoreStoreDemo/CoreStoreDemo/Stack Setup Demo/StackSetupDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/Stack Setup Demo/StackSetupDemoViewController.swift @@ -19,12 +19,12 @@ private struct Static { let dataStack = DataStack(modelName: "StackSetupDemo") dataStack.addSQLiteStoreAndWait( - "AccountsDemo_FB_Male.sqlite", + fileName: "AccountsDemo_FB_Male.sqlite", configuration: maleConfiguration, resetStoreOnMigrationFailure: true ) dataStack.addSQLiteStoreAndWait( - "AccountsDemo_FB_Female.sqlite", + fileName: "AccountsDemo_FB_Female.sqlite", configuration: femaleConfiguration, resetStoreOnMigrationFailure: true ) @@ -53,12 +53,12 @@ private struct Static { let dataStack = DataStack(modelName: "StackSetupDemo") dataStack.addSQLiteStoreAndWait( - "AccountsDemo_TW_Male.sqlite", + fileName: "AccountsDemo_TW_Male.sqlite", configuration: maleConfiguration, resetStoreOnMigrationFailure: true ) dataStack.addSQLiteStoreAndWait( - "AccountsDemo_TW_Female.sqlite", + fileName: "AccountsDemo_TW_Female.sqlite", configuration: femaleConfiguration, resetStoreOnMigrationFailure: true ) diff --git a/CoreStoreDemo/CoreStoreDemo/Transactions Demo/TransactionsDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/Transactions Demo/TransactionsDemoViewController.swift index 57e4225..d605ac3 100644 --- a/CoreStoreDemo/CoreStoreDemo/Transactions Demo/TransactionsDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/Transactions Demo/TransactionsDemoViewController.swift @@ -19,7 +19,7 @@ private struct Static { static let placeController: ObjectMonitor = { CoreStore.addSQLiteStoreAndWait( - "PlaceDemo.sqlite", + fileName: "PlaceDemo.sqlite", configuration: "TransactionsDemo", resetStoreOnMigrationFailure: true ) diff --git a/CoreStoreTests/CoreStoreTests.swift b/CoreStoreTests/CoreStoreTests.swift index 676c96d..5c124e9 100644 --- a/CoreStoreTests/CoreStoreTests.swift +++ b/CoreStoreTests/CoreStoreTests.swift @@ -47,7 +47,7 @@ class CoreStoreTests: XCTestCase { CoreStore.defaultStack = stack XCTAssert(CoreStore.defaultStack === stack, "CoreStore.defaultStack === stack") - switch stack.addSQLiteStoreAndWait("ConfigStore1.sqlite", configuration: "Config1", resetStoreOnMigrationFailure: true){ + switch stack.addSQLiteStoreAndWait(fileName: "ConfigStore1.sqlite", configuration: "Config1", resetStoreOnMigrationFailure: true){ case .Failure(let error): XCTFail(error.description) @@ -56,7 +56,7 @@ class CoreStoreTests: XCTestCase { break } - switch stack.addSQLiteStoreAndWait("ConfigStore2.sqlite", configuration: "Config2", resetStoreOnMigrationFailure: true){ + switch stack.addSQLiteStoreAndWait(fileName: "ConfigStore2.sqlite", configuration: "Config2", resetStoreOnMigrationFailure: true){ case .Failure(let error): XCTFail(error.description) diff --git a/README.md b/README.md index c4d2912..3701140 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ I wrote this library when Swift was made public, and CoreStore is now a powerhou Quick-setup: ```swift -CoreStore.addSQLiteStoreAndWait("MyStore.sqlite") +CoreStore.addSQLiteStoreAndWait(fileName: "MyStore.sqlite") ``` Simple transactions: