require explicit parameter for fileName when calling addSQLiteStore() and it's variants

This commit is contained in:
John Estropia
2015-07-09 21:28:37 +09:00
parent 35fbaf9513
commit b2a190ea33
11 changed files with 19 additions and 19 deletions

View File

@@ -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(

View File

@@ -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

View File

@@ -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(

View File

@@ -16,7 +16,7 @@ private struct Static {
let dataStack = DataStack()
dataStack.addSQLiteStoreAndWait(
"TimeZoneDemo.sqlite",
fileName: "TimeZoneDemo.sqlite",
configuration: "FetchingAndQueryingDemo",
resetStoreOnMigrationFailure: true
)

View File

@@ -15,7 +15,7 @@ private struct Static {
static let palettes: ListMonitor<Palette> = {
CoreStore.addSQLiteStoreAndWait(
"ColorsDemo.sqlite",
fileName: "ColorsDemo.sqlite",
configuration: "ObservingDemo",
resetStoreOnMigrationFailure: true
)

View File

@@ -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

View File

@@ -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 {

View File

@@ -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
)

View File

@@ -19,7 +19,7 @@ private struct Static {
static let placeController: ObjectMonitor<Place> = {
CoreStore.addSQLiteStoreAndWait(
"PlaceDemo.sqlite",
fileName: "PlaceDemo.sqlite",
configuration: "TransactionsDemo",
resetStoreOnMigrationFailure: true
)

View File

@@ -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)

View File

@@ -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: