diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index ebabb75..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-language: objective-c
-osx_image: xcode11
-sudo: false
-git:
- submodules: false
-notifications:
- email: false
-env:
- global:
- - LC_CTYPE=en_US.UTF-8
- - LANG=en_US.UTF-8
- matrix:
- - DESTINATION="arch=x86_64" SCHEME="CoreStore OSX" SDK=macosx10.14 RUN_TESTS="YES" POD_LINT="NO"
- - DESTINATION="OS=12.0,name=iPhone XS" SCHEME="CoreStore iOS" SDK=iphonesimulator13.0 RUN_TESTS="YES" POD_LINT="NO"
- - DESTINATION="OS=11.0.1,name=iPhone 8" SCHEME="CoreStore iOS" SDK=iphonesimulator13.0 RUN_TESTS="YES" POD_LINT="NO"
- - DESTINATION="OS=10.3.1,name=iPhone 7" SCHEME="CoreStore iOS" SDK=iphonesimulator13.0 RUN_TESTS="YES" POD_LINT="NO"
- - DESTINATION="OS=10.1,name=iPhone 7" SCHEME="CoreStore iOS" SDK=iphonesimulator13.0 RUN_TESTS="YES" POD_LINT="NO"
- - DESTINATION="OS=4.0,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator6.0 RUN_TESTS="NO" POD_LINT="NO"
- - DESTINATION="OS=3.2,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator6.0 RUN_TESTS="NO" POD_LINT="NO"
- - DESTINATION="OS=2.2,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator6.0 RUN_TESTS="NO" POD_LINT="NO"
- - DESTINATION="OS=12.0,name=Apple TV 4K" SCHEME="CoreStore tvOS" SDK=appletvsimulator13.0 RUN_TESTS="YES" POD_LINT="NO"
- - DESTINATION="OS=11.0,name=Apple TV 4K (at 1080p)" SCHEME="CoreStore tvOS" SDK=appletvsimulator13.0 RUN_TESTS="YES" POD_LINT="NO"
- - DESTINATION="OS=10.2,name=Apple TV 1080p" SCHEME="CoreStore tvOS" SDK=appletvsimulator13.0 RUN_TESTS="YES" POD_LINT="NO"
-before_install:
- - gem install cocoapods --no-rdoc --no-ri --no-document
- - gem install xcpretty --no-rdoc --no-ri --no-document
- - npm install ios-sim -g
- - ios-sim start --devicetypeid "com.apple.CoreSimulator.SimDeviceType.iPhone-8, 11.0"
-script:
- - set -o pipefail
- - xcodebuild -version
- - xcodebuild -showsdks
- - if [ $RUN_TESTS == "YES" ]; then
- xcodebuild -workspace CoreStore.xcworkspace -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c;
- xcodebuild -workspace CoreStore.xcworkspace -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c;
- fi
- - xcodebuild -workspace "CoreStore.xcworkspace" -scheme "CoreStoreDemo" -sdk "iphonesimulator13.0" -destination "OS=13.0,name=iPhone 8" -configuration Debug ONLY_ACTIVE_ARCH=NO build | xcpretty -c;
- - xcodebuild -workspace "CoreStore.xcworkspace" -scheme "CoreStoreDemo" -sdk "iphonesimulator13.0" -destination "OS=13.0,name=iPhone 8" -configuration Release ONLY_ACTIVE_ARCH=NO build | xcpretty -c;
- - if [ $POD_LINT == "YES" ]; then
- pod lib lint --quick;
- fi
diff --git a/CoreStore.podspec b/CoreStore.podspec
index fdb9527..549d04e 100644
--- a/CoreStore.podspec
+++ b/CoreStore.podspec
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "CoreStore"
- s.version = "6.3.2"
- s.swift_version = "5.0"
+ s.version = "7.0.0"
+ s.swift_version = "5.1"
s.license = "MIT"
s.homepage = "https://github.com/JohnEstropia/CoreStore"
s.documentation_url = "https://JohnEstropia.github.io/CoreStore"
diff --git a/CoreStore.xcodeproj/project.pbxproj b/CoreStore.xcodeproj/project.pbxproj
index bee2174..c767761 100644
--- a/CoreStore.xcodeproj/project.pbxproj
+++ b/CoreStore.xcodeproj/project.pbxproj
@@ -465,10 +465,10 @@
B56321B31BD6521C006C9394 /* NSManagedObjectContext+Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F321AFF85470064E85B /* NSManagedObjectContext+Setup.swift */; };
B56321B41BD6521C006C9394 /* NSManagedObjectContext+Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F331AFF85470064E85B /* NSManagedObjectContext+Transaction.swift */; };
B56321B61BD6521C006C9394 /* Internals.WeakObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F2D1AFF849C0064E85B /* Internals.WeakObject.swift */; };
- B5635D142356C39500B80E6B /* DiffableDataSource.CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView.swift */; };
- B5635D152356C39500B80E6B /* DiffableDataSource.CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView.swift */; };
- B5635D162356C39500B80E6B /* DiffableDataSource.CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView.swift */; };
- B5635D172356C39500B80E6B /* DiffableDataSource.CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView.swift */; };
+ B5635D142356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift */; };
+ B5635D152356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift */; };
+ B5635D162356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift */; };
+ B5635D172356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift */; };
B56507941D3930BC000596DA /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507931D3930BC000596DA /* CoreData.framework */; };
B56507961D3930C1000596DA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507951D3930C1000596DA /* Foundation.framework */; };
B56507981D3930CC000596DA /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507971D3930CC000596DA /* CoreData.framework */; };
@@ -580,6 +580,11 @@
B5A992201EA898720091A2E3 /* UserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5A9921E1EA898710091A2E3 /* UserInfo.swift */; };
B5A992211EA898720091A2E3 /* UserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5A9921E1EA898710091A2E3 /* UserInfo.swift */; };
B5A992221EA898720091A2E3 /* UserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5A9921E1EA898710091A2E3 /* UserInfo.swift */; };
+ B5AA37F1235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AA37F0235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift */; };
+ B5AA37F2235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AA37F0235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift */; };
+ B5AA37F3235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AA37F0235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift */; };
+ B5AA37F4235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AA37F0235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift */; };
+ B5AA37FD235C3D1A00FFD4B9 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5AA37FC235C3D1A00FFD4B9 /* SwiftUI.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
B5AEFAB51C9962AE00AD137F /* CoreStoreBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AEFAB41C9962AE00AD137F /* CoreStoreBridge.swift */; };
B5AEFAB61C9962AE00AD137F /* CoreStoreBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AEFAB41C9962AE00AD137F /* CoreStoreBridge.swift */; };
B5AEFAB71C9962AE00AD137F /* CoreStoreBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AEFAB41C9962AE00AD137F /* CoreStoreBridge.swift */; };
@@ -592,10 +597,10 @@
B5BF7FB3234C97910070E741 /* DiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB1234C97910070E741 /* DiffableDataSource.swift */; };
B5BF7FB4234C97910070E741 /* DiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB1234C97910070E741 /* DiffableDataSource.swift */; };
B5BF7FB5234C97910070E741 /* DiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB1234C97910070E741 /* DiffableDataSource.swift */; };
- B5BF7FB7234C97CE0070E741 /* DiffableDataSource.TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView.swift */; };
- B5BF7FB8234C97CE0070E741 /* DiffableDataSource.TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView.swift */; };
- B5BF7FB9234C97CE0070E741 /* DiffableDataSource.TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView.swift */; };
- B5BF7FBA234C97CE0070E741 /* DiffableDataSource.TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView.swift */; };
+ B5BF7FB7234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift */; };
+ B5BF7FB8234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift */; };
+ B5BF7FB9234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift */; };
+ B5BF7FBA234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift */; };
B5BF7FBC234C99190070E741 /* Internals.DiffableDataUIDispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FBB234C99190070E741 /* Internals.DiffableDataUIDispatcher.swift */; };
B5BF7FBD234C99190070E741 /* Internals.DiffableDataUIDispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FBB234C99190070E741 /* Internals.DiffableDataUIDispatcher.swift */; };
B5BF7FBE234C99190070E741 /* Internals.DiffableDataUIDispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FBB234C99190070E741 /* Internals.DiffableDataUIDispatcher.swift */; };
@@ -694,10 +699,10 @@
B5DE522C230BD7D500A22534 /* Internals.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522A230BD7CC00A22534 /* Internals.swift */; };
B5DE522D230BD7D600A22534 /* Internals.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522A230BD7CC00A22534 /* Internals.swift */; };
B5DE522E230BD7D600A22534 /* Internals.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522A230BD7CC00A22534 /* Internals.swift */; };
- B5DE5230230BDA1300A22534 /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* Shared.swift */; };
- B5DE5231230BDA1300A22534 /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* Shared.swift */; };
- B5DE5232230BDA1300A22534 /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* Shared.swift */; };
- B5DE5233230BDA1300A22534 /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* Shared.swift */; };
+ B5DE5230230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* CoreStoreDefaults.swift */; };
+ B5DE5231230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* CoreStoreDefaults.swift */; };
+ B5DE5232230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* CoreStoreDefaults.swift */; };
+ B5DE5233230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* CoreStoreDefaults.swift */; };
B5E1B5931CAA0C15007FD580 /* CSObjectMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E1B5921CAA0C15007FD580 /* CSObjectMonitor.swift */; };
B5E1B5951CAA0C15007FD580 /* CSObjectMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E1B5921CAA0C15007FD580 /* CSObjectMonitor.swift */; };
B5E1B5961CAA0C15007FD580 /* CSObjectMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E1B5921CAA0C15007FD580 /* CSObjectMonitor.swift */; };
@@ -875,7 +880,6 @@
82BA18921C4BBCBA00A0916E /* CoreStoreTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoreStoreTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
82BA18DE1C4BBE2600A0916E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
82BA18E01C4BBE2C00A0916E /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; };
- B500810F2290CDF800F4CEA5 /* bitrise.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = bitrise.yml; sourceTree = SOURCE_ROOT; };
B50132292344ECB500FC238B /* ListPublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPublisher.swift; sourceTree = "
-
+
@@ -14,15 +14,15 @@ Unleashing the real power of Core Data with the elegance and safety of Swift
Contact
-
-
+
+
-In our sample code above, note that you don't need to do the `CoreStore.defaultStack = dataStack` line. You can just as well hold a reference to the `DataStack` like below and call all its instance methods directly:
+In our sample code above, note that you don't need to do the `CoreStoreDefaults.dataStack = dataStack` line. You can just as well hold a reference to the `DataStack` like below and call all its instance methods directly:
```swift
class MyViewController: UIViewController {
let dataStack = DataStack(xcodeModelName: "MyModel") // keep reference to the stack
@@ -247,24 +247,6 @@ class MyViewController: UIViewController {
}
}
```
-The difference is when you set the stack as the `CoreStore.defaultStack`, you can call the stack's methods directly from `CoreStore` itself:
-```swift
-class MyViewController: UIViewController {
- // elsewhere: CoreStore.defaultStack = DataStack(modelName: "MyModel")
- override func viewDidLoad() {
- super.viewDidLoad()
- do {
- try CoreStore.addStorageAndWait(SQLiteStore.self)
- }
- catch { // ...
- }
- }
- func methodToBeCalledLaterOn() {
- let objects = CoreStore.fetchAll(From
-try CoreStore.addStorageAndWait(SQLiteStore.self)
+try dataStack.addStorageAndWait(SQLiteStore.self)
NSError *error
@@ -1599,7 +1581,7 @@ NSError *error
-CoreStore.perform(
+dataStack.perform(
asynchronous: { (transaction) in
// ...
},
@@ -1631,7 +1613,7 @@ All of these `CS`-prefixed bridging classes have very similar usage to the exist
For example, you may have a new, modern Swift class that holds a `ListMonitor`:
```swift
class MyViewController: UIViewController {
- let monitor = CoreStore.monitorList(From(), ...)
+ let monitor = dataStack.monitorList(From(), ...)
// ...
}
```
@@ -1645,7 +1627,7 @@ Now let's say you have a legacy Objective-C class that previously uses `NSFetche
When you need to instantiate this class from Swift, you just call `bridgeToObjectiveC`:
```swift
class MyViewController: UIViewController {
- let monitor = CoreStore.monitorList(From(), ...)
+ let monitor = dataStack.monitorList(From(), ...)
func showOldController() {
let controller = MYOldViewController(monitor: self.monitor.bridgeToObjectiveC)
self.presentViewController(controller, animated: true, completion: nil)
@@ -1719,7 +1701,7 @@ Also note how `Relationship`s are linked statically with the `inverse:` argument
To tell the `DataStack` about these types, add all `CoreStoreObject`s' entities to a `CoreStoreSchema`:
```swift
-CoreStore.defaultStack = DataStack(
+CoreStoreDefaults.dataStack = DataStack(
CoreStoreSchema(
modelVersion: "V1",
entities: [
@@ -1729,13 +1711,13 @@ CoreStore.defaultStack = DataStack(
]
)
)
-CoreStore.addStorage(/* ... */)
+CoreStoreDefaults.dataStack.addStorage(/* ... */)
```
And that's all CoreStore needs to build the model; **we don't need *.xcdatamodeld* files anymore.**
These special properties' values can be accessed or mutated using `.value`:
```swift
-CoreStore.perform(
+dataStack.perform(
asynchronous: { (transaction) in
let dog: Dog = transaction.fetchOne(From())!
// ...
@@ -1755,7 +1737,7 @@ let keyPath: String = Dog.keyPath { $0.nickname }
```
as well as `Where` and `OrderBy` clauses
```swift
-let puppies = try CoreStore.fetchAll(
+let puppies = try dataStack.fetchAll(
From()
.where(\.age < 1)
.orderBy(.ascending(\.age))
@@ -1790,7 +1772,7 @@ CoreStoreSchema(
```
You can also get this hash after the `DataStack` has been fully set up by printing to the console:
```swift
-print(CoreStore.defaultStack.modelSchema.printCoreStoreSchema())
+print(CoreStoreDefaults.dataStack.modelSchema.printCoreStoreSchema())
```
Once the version lock is set, any changes in the properties or to the model will trigger an assertion failure similar to this:
@@ -1811,7 +1793,7 @@ Once the version lock is set, any changes in the properties or to the model will
### Install with CocoaPods
In your `Podfile`, add
```
-pod 'CoreStore', '~> 6.3'
+pod 'CoreStore', '~> 7.0'
```
and run
```
@@ -1822,7 +1804,7 @@ This installs CoreStore as a framework. Declare `import CoreStore` in your swift
### Install with Carthage
In your `Cartfile`, add
```
-github "JohnEstropia/CoreStore" >= 6.3.0
+github "JohnEstropia/CoreStore" >= 7.0.0
```
and run
```
@@ -1833,7 +1815,7 @@ This installs CoreStore as a framework. Declare `import CoreStore` in your swift
#### Install with Swift Package Manager:
```swift
dependencies: [
- .package(url: "https://github.com/JohnEstropia/CoreStore.git", from: "6.3.0"))
+ .package(url: "https://github.com/JohnEstropia/CoreStore.git", from: "7.0.0"))
]
```
Declare `import CoreStore` in your swift file to use the library.
diff --git a/Sources/AsynchronousDataTransaction.swift b/Sources/AsynchronousDataTransaction.swift
index 988e337..002f566 100644
--- a/Sources/AsynchronousDataTransaction.swift
+++ b/Sources/AsynchronousDataTransaction.swift
@@ -30,7 +30,7 @@ import CoreData
// MARK: - AsynchronousDataTransaction
/**
- The `AsynchronousDataTransaction` provides an interface for `DynamicObject` creates, updates, and deletes. A transaction object should typically be only used from within a transaction block initiated from `DataStack.perform(asynchronous:...)`, or from `CoreStore.perform(synchronous:...)`.
+ The `AsynchronousDataTransaction` provides an interface for `DynamicObject` creates, updates, and deletes. A transaction object should typically be only used from within a transaction block initiated from `DataStack.perform(asynchronous:...)`.
*/
public final class AsynchronousDataTransaction: BaseDataTransaction {
diff --git a/Sources/CSCoreStore+Setup.swift b/Sources/CSCoreStore+Setup.swift
index 0028a94..6665205 100644
--- a/Sources/CSCoreStore+Setup.swift
+++ b/Sources/CSCoreStore+Setup.swift
@@ -38,7 +38,7 @@ extension CSCoreStore {
@objc
public static var modelVersion: String {
- return CoreStore.modelVersion
+ return self.defaultStack.modelVersion
}
/**
@@ -47,7 +47,7 @@ extension CSCoreStore {
@objc
public static func entityTypesByNameForType(_ type: NSManagedObject.Type) -> [EntityName: NSManagedObject.Type] {
- return CoreStore.entityTypesByName(for: type)
+ return self.defaultStack.bridgeToSwift.entityTypesByName(for: type)
}
/**
@@ -56,7 +56,7 @@ extension CSCoreStore {
@objc
public static func entityDescriptionForClass(_ type: NSManagedObject.Type) -> NSEntityDescription? {
- return CoreStore.entityDescription(for: type)
+ return self.defaultStack.bridgeToSwift.entityDescription(for: type)
}
/**
diff --git a/Sources/CSCoreStore+Transaction.swift b/Sources/CSCoreStore+Transaction.swift
index bda8282..53a4f9f 100644
--- a/Sources/CSCoreStore+Transaction.swift
+++ b/Sources/CSCoreStore+Transaction.swift
@@ -65,7 +65,7 @@ extension CSCoreStore {
return bridge {
- CoreStore.beginUnsafe()
+ self.defaultStack.bridgeToSwift.beginUnsafe()
}
}
@@ -80,7 +80,7 @@ extension CSCoreStore {
return bridge {
- CoreStore.beginUnsafe(supportsUndo: supportsUndo)
+ self.defaultStack.bridgeToSwift.beginUnsafe(supportsUndo: supportsUndo)
}
}
@@ -90,6 +90,6 @@ extension CSCoreStore {
@objc
public static func refreshAndMergeAllObjects() {
- CoreStore.refreshAndMergeAllObjects()
+ self.defaultStack.refreshAndMergeAllObjects()
}
}
diff --git a/Sources/CSCoreStore.swift b/Sources/CSCoreStore.swift
index ef5709b..c07e675 100644
--- a/Sources/CSCoreStore.swift
+++ b/Sources/CSCoreStore.swift
@@ -46,8 +46,8 @@ public final class CSCoreStore: NSObject {
@objc
public static var defaultStack: CSDataStack {
- get { return Shared.defaultStack.bridgeToObjectiveC }
- set { Shared.defaultStack = newValue.bridgeToSwift }
+ get { return CoreStoreDefaults.dataStack.bridgeToObjectiveC }
+ set { CoreStoreDefaults.dataStack = newValue.bridgeToSwift }
}
diff --git a/Sources/CoreStore+Logging.swift b/Sources/CoreStore+Logging.swift
index b2fe6ed..d984871 100644
--- a/Sources/CoreStore+Logging.swift
+++ b/Sources/CoreStore+Logging.swift
@@ -35,7 +35,7 @@ extension Internals {
@inline(__always)
internal static func log(_ level: LogLevel, message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) {
- Shared.logger.log(
+ CoreStoreDefaults.logger.log(
level: level,
message: message,
fileName: fileName,
@@ -47,7 +47,7 @@ extension Internals {
@inline(__always)
internal static func log(_ error: CoreStoreError, _ message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) {
- Shared.logger.log(
+ CoreStoreDefaults.logger.log(
error: error,
message: message,
fileName: fileName,
@@ -59,7 +59,7 @@ extension Internals {
@inline(__always)
internal static func assert( _ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) {
- Shared.logger.assert(
+ CoreStoreDefaults.logger.assert(
condition(),
message: message(),
fileName: fileName,
@@ -71,7 +71,7 @@ extension Internals {
@inline(__always)
internal static func abort(_ message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) -> Never {
- Shared.logger.abort(
+ CoreStoreDefaults.logger.abort(
message,
fileName: fileName,
lineNumber: lineNumber,
diff --git a/Sources/CoreStore+Migration.swift b/Sources/CoreStore+Migration.swift
index 0615d7c..e0dac94 100644
--- a/Sources/CoreStore+Migration.swift
+++ b/Sources/CoreStore+Migration.swift
@@ -33,9 +33,9 @@ import CoreData
extension CoreStore {
/**
- Asynchronously adds a `StorageInterface` to the `defaultStack`. Migrations are also initiated by default.
+ Asynchronously adds a `StorageInterface` to the `CoreStoreDefaults.dataStack`. Migrations are also initiated by default.
```
- CoreStore.addStorage(
+ dataStack.addStorage(
InMemoryStore(configuration: "Config1"),
completion: { result in
switch result {
@@ -50,13 +50,13 @@ extension CoreStore {
*/
public static func addStorage(_ storage: T, completion: @escaping (SetupResult) -> Void) {
- Shared.defaultStack.addStorage(storage, completion: completion)
+ CoreStoreDefaults.dataStack.addStorage(storage, completion: completion)
}
/**
- Asynchronously adds a `LocalStorage` to the `defaultStack`. Migrations are also initiated by default.
+ Asynchronously adds a `LocalStorage` to the `CoreStoreDefaults.dataStack`. Migrations are also initiated by default.
```
- let migrationProgress = CoreStore.addStorage(
+ let migrationProgress = dataStack.addStorage(
SQLiteStore(fileName: "core_data.sqlite", configuration: "Config1"),
completion: { result in
switch result {
@@ -72,11 +72,11 @@ extension CoreStore {
*/
public static func addStorage(_ storage: T, completion: @escaping (SetupResult) -> Void) -> Progress? {
- return Shared.defaultStack.addStorage(storage, completion: completion)
+ return CoreStoreDefaults.dataStack.addStorage(storage, completion: completion)
}
/**
- Asynchronously adds a `CloudStorage` to the `defaultStack`. Migrations are also initiated by default.
+ Asynchronously adds a `CloudStorage` to the `CoreStoreDefaults.dataStack`. Migrations are also initiated by default.
```
guard let storage = ICloudStore(
ubiquitousContentName: "MyAppCloudData",
@@ -104,11 +104,11 @@ extension CoreStore {
*/
public static func addStorage(_ storage: T, completion: @escaping (SetupResult) -> Void) {
- Shared.defaultStack.addStorage(storage, completion: completion)
+ CoreStoreDefaults.dataStack.addStorage(storage, completion: completion)
}
/**
- 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.
+ Migrates a local storage to match the `CoreStoreDefaults.dataStack`'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.
@@ -117,11 +117,11 @@ extension CoreStore {
*/
public static func upgradeStorageIfNeeded(_ storage: T, completion: @escaping (MigrationResult) -> Void) throws -> Progress? {
- return try Shared.defaultStack.upgradeStorageIfNeeded(storage, completion: completion)
+ return try CoreStoreDefaults.dataStack.upgradeStorageIfNeeded(storage, completion: completion)
}
/**
- Checks the migration steps required for the storage to match the `defaultStack`'s managed object model version.
+ Checks the migration steps required for the storage to match the `CoreStoreDefaults.dataStack`'s managed object model version.
- parameter storage: the local storage
- throws: a `CoreStoreError` value indicating the failure
@@ -129,6 +129,6 @@ extension CoreStore {
*/
public static func requiredMigrationsForStorage(_ storage: T) throws -> [MigrationType] {
- return try Shared.defaultStack.requiredMigrationsForStorage(storage)
+ return try CoreStoreDefaults.dataStack.requiredMigrationsForStorage(storage)
}
}
diff --git a/Sources/CoreStore+Observing.swift b/Sources/CoreStore+Observing.swift
index a8aa4dd..94fd5b7 100644
--- a/Sources/CoreStore+Observing.swift
+++ b/Sources/CoreStore+Observing.swift
@@ -34,18 +34,18 @@ import CoreData
extension CoreStore {
/**
- Using the `defaultStack`, creates an `ObjectMonitor` for the specified `DynamicObject`. Multiple `ObjectObserver`s may then register themselves to be notified when changes are made to the `DynamicObject`.
+ Using the `CoreStoreDefaults.dataStack`, creates an `ObjectMonitor` for the specified `DynamicObject`. Multiple `ObjectObserver`s may then register themselves to be notified when changes are made to the `DynamicObject`.
- parameter object: the `DynamicObject` to observe changes from
- returns: an `ObjectMonitor` that monitors changes to `object`
*/
public static func monitorObject(_ object: O) -> ObjectMonitor {
- return Shared.defaultStack.monitorObject(object)
+ return CoreStoreDefaults.dataStack.monitorObject(object)
}
/**
- Using the `defaultStack`, creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list.
+ Using the `CoreStoreDefaults.dataStack`, creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -53,11 +53,11 @@ extension CoreStore {
*/
public static func monitorList(_ from: From, _ fetchClauses: FetchClause...) -> ListMonitor {
- return Shared.defaultStack.monitorList(from, fetchClauses)
+ return CoreStoreDefaults.dataStack.monitorList(from, fetchClauses)
}
/**
- Using the `defaultStack`, creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list.
+ Using the `CoreStoreDefaults.dataStack`, creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -65,13 +65,13 @@ extension CoreStore {
*/
public static func monitorList(_ from: From, _ fetchClauses: [FetchClause]) -> ListMonitor {
- return Shared.defaultStack.monitorList(from, fetchClauses)
+ return CoreStoreDefaults.dataStack.monitorList(from, fetchClauses)
}
/**
Creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
```
- let monitor = CoreStore.monitorList(
+ let monitor = dataStack.monitorList(
From()
.where(\.age > 18)
.orderBy(.ascending(\.age))
@@ -82,11 +82,11 @@ extension CoreStore {
*/
public static func monitorList(_ clauseChain: B) -> ListMonitor {
- return Shared.defaultStack.monitorList(clauseChain.from, clauseChain.fetchClauses)
+ return CoreStoreDefaults.dataStack.monitorList(clauseChain.from, clauseChain.fetchClauses)
}
/**
- Using the `defaultStack`, asynchronously creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list. Since `NSFetchedResultsController` greedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.
+ Using the `CoreStoreDefaults.dataStack`, asynchronously creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list. Since `NSFetchedResultsController` greedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter from: a `From` clause indicating the entity type
@@ -94,11 +94,11 @@ extension CoreStore {
*/
public static func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: FetchClause...) {
- Shared.defaultStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
+ CoreStoreDefaults.dataStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
}
/**
- Using the `defaultStack`, asynchronously creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list. Since `NSFetchedResultsController` greedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.
+ Using the `CoreStoreDefaults.dataStack`, asynchronously creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list. Since `NSFetchedResultsController` greedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter from: a `From` clause indicating the entity type
@@ -106,14 +106,14 @@ extension CoreStore {
*/
public static func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: [FetchClause]) {
- Shared.defaultStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
+ CoreStoreDefaults.dataStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
}
/**
Asynchronously creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses. Since `NSFetchedResultsController` greedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.
```
- CoreStore.monitorList(
+ dataStack.monitorList(
createAsynchronously: { (monitor) in
self.monitor = monitor
},
@@ -127,7 +127,7 @@ extension CoreStore {
*/
public static func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ clauseChain: B) {
- Shared.defaultStack.monitorList(
+ CoreStoreDefaults.dataStack.monitorList(
createAsynchronously: createAsynchronously,
clauseChain.from,
clauseChain.fetchClauses
@@ -135,7 +135,7 @@ extension CoreStore {
}
/**
- Using the `defaultStack`, creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list.
+ Using the `CoreStoreDefaults.dataStack`, creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list.
- parameter from: a `From` clause indicating the entity type
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
@@ -144,11 +144,11 @@ extension CoreStore {
*/
public static func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor {
- return Shared.defaultStack.monitorSectionedList(from, sectionBy, fetchClauses)
+ return CoreStoreDefaults.dataStack.monitorSectionedList(from, sectionBy, fetchClauses)
}
/**
- Using the `defaultStack`, creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list.
+ Using the `CoreStoreDefaults.dataStack`, creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list.
- parameter from: a `From` clause indicating the entity type
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
@@ -157,13 +157,13 @@ extension CoreStore {
*/
public static func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor {
- return Shared.defaultStack.monitorSectionedList(from, sectionBy, fetchClauses)
+ return CoreStoreDefaults.dataStack.monitorSectionedList(from, sectionBy, fetchClauses)
}
/**
Creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType` built from a chain of clauses.
```
- let monitor = CoreStore.monitorSectionedList(
+ let monitor = dataStack.monitorSectionedList(
From()
.sectionBy(\.age, { "\($0!) years old" })
.where(\.age > 18)
@@ -175,7 +175,7 @@ extension CoreStore {
*/
public static func monitorSectionedList(_ clauseChain: B) -> ListMonitor {
- return Shared.defaultStack.monitorSectionedList(
+ return CoreStoreDefaults.dataStack.monitorSectionedList(
clauseChain.from,
clauseChain.sectionBy,
clauseChain.fetchClauses
@@ -183,7 +183,7 @@ extension CoreStore {
}
/**
- Using the `defaultStack`, asynchronously creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list. Since `NSFetchedResultsController` greedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.
+ Using the `CoreStoreDefaults.dataStack`, asynchronously creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list. Since `NSFetchedResultsController` greedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter from: a `From` clause indicating the entity type
@@ -192,11 +192,11 @@ extension CoreStore {
*/
public static func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
- Shared.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
+ CoreStoreDefaults.dataStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}
/**
- Using the `defaultStack`, asynchronously creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list. Since `NSFetchedResultsController` greedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.
+ Using the `CoreStoreDefaults.dataStack`, asynchronously creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified fetch clauses. Multiple `ListObserver`s may then register themselves to be notified when changes are made to the list. Since `NSFetchedResultsController` greedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter from: a `From` clause indicating the entity type
@@ -205,13 +205,13 @@ extension CoreStore {
*/
public static func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
- Shared.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
+ CoreStoreDefaults.dataStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}
/**
Asynchronously creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType` built from a chain of clauses.
```
- CoreStore.monitorSectionedList(
+ dataStack.monitorSectionedList(
createAsynchronously: { (monitor) in
self.monitor = monitor
},
@@ -226,7 +226,7 @@ extension CoreStore {
*/
public static func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ clauseChain: B) {
- Shared.defaultStack.monitorSectionedList(
+ CoreStoreDefaults.dataStack.monitorSectionedList(
createAsynchronously: createAsynchronously,
clauseChain.from,
clauseChain.sectionBy,
diff --git a/Sources/CoreStore+Querying.swift b/Sources/CoreStore+Querying.swift
index aa33d1d..9ccb96e 100644
--- a/Sources/CoreStore+Querying.swift
+++ b/Sources/CoreStore+Querying.swift
@@ -33,51 +33,51 @@ import CoreData
extension CoreStore {
/**
- Using the `defaultStack`, fetches the `DynamicObject` instance in the `DataStack`'s context from a reference created from a transaction or from a different managed object context.
+ Using the `CoreStoreDefaults.dataStack`, fetches the `DynamicObject` instance in the `DataStack`'s context from a reference created from a transaction or from a different managed object context.
- parameter object: a reference to the object created/fetched outside the `DataStack`
- returns: the `DynamicObject` instance if the object exists in the `DataStack`, or `nil` if not found.
*/
public static func fetchExisting(_ object: D) -> D? {
- return Shared.defaultStack.fetchExisting(object)
+ return CoreStoreDefaults.dataStack.fetchExisting(object)
}
/**
- Using the `defaultStack`, fetches the `DynamicObject` instance in the `DataStack`'s context from an `NSManagedObjectID`.
+ Using the `CoreStoreDefaults.dataStack`, fetches the `DynamicObject` instance in the `DataStack`'s context from an `NSManagedObjectID`.
- parameter objectID: the `NSManagedObjectID` for the object
- returns: the `DynamicObject` instance if the object exists in the `DataStack`, or `nil` if not found.
*/
public static func fetchExisting(_ objectID: NSManagedObjectID) -> D? {
- return Shared.defaultStack.fetchExisting(objectID)
+ return CoreStoreDefaults.dataStack.fetchExisting(objectID)
}
/**
- Using the `defaultStack`, fetches the `DynamicObject` instances in the `DataStack`'s context from references created from a transaction or from a different managed object context.
+ Using the `CoreStoreDefaults.dataStack`, fetches the `DynamicObject` instances in the `DataStack`'s context from references created from a transaction or from a different managed object context.
- parameter objects: an array of `DynamicObject`s created/fetched outside the `DataStack`
- returns: the `DynamicObject` array for objects that exists in the `DataStack`
*/
public static func fetchExisting(_ objects: S) -> [D] where S.Iterator.Element == D {
- return Shared.defaultStack.fetchExisting(objects)
+ return CoreStoreDefaults.dataStack.fetchExisting(objects)
}
/**
- Using the `defaultStack`, fetches the `DynamicObject` instances in the `DataStack`'s context from a list of `NSManagedObjectID`.
+ Using the `CoreStoreDefaults.dataStack`, fetches the `DynamicObject` instances in the `DataStack`'s context from a list of `NSManagedObjectID`.
- parameter objectIDs: the `NSManagedObjectID` array for the objects
- returns: the `DynamicObject` array for objects that exists in the `DataStack`
*/
public static func fetchExisting(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID {
- return Shared.defaultStack.fetchExisting(objectIDs)
+ return CoreStoreDefaults.dataStack.fetchExisting(objectIDs)
}
/**
- Using the `defaultStack`, fetches the first `DynamicObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, fetches the first `DynamicObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -86,11 +86,11 @@ extension CoreStore {
*/
public static func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> D? {
- return try Shared.defaultStack.fetchOne(from, fetchClauses)
+ return try CoreStoreDefaults.dataStack.fetchOne(from, fetchClauses)
}
/**
- Using the `defaultStack`, fetches the first `DynamicObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, fetches the first `DynamicObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -99,13 +99,13 @@ extension CoreStore {
*/
public static func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> D? {
- return try Shared.defaultStack.fetchOne(from, fetchClauses)
+ return try CoreStoreDefaults.dataStack.fetchOne(from, fetchClauses)
}
/**
Fetches the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType` built from a chain of clauses.
```
- let youngestTeen = CoreStore.fetchOne(
+ let youngestTeen = dataStack.fetchOne(
From()
.where(\.age > 18)
.orderBy(.ascending(\.age))
@@ -117,11 +117,11 @@ extension CoreStore {
*/
public static func fetchOne(_ clauseChain: B) throws -> B.ObjectType? {
- return try Shared.defaultStack.fetchOne(clauseChain)
+ return try CoreStoreDefaults.dataStack.fetchOne(clauseChain)
}
/**
- Using the `defaultStack`, fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -130,11 +130,11 @@ extension CoreStore {
*/
public static func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [D] {
- return try Shared.defaultStack.fetchAll(from, fetchClauses)
+ return try CoreStoreDefaults.dataStack.fetchAll(from, fetchClauses)
}
/**
- Using the `defaultStack`, fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -143,13 +143,13 @@ extension CoreStore {
*/
public static func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [D] {
- return try Shared.defaultStack.fetchAll(from, fetchClauses)
+ return try CoreStoreDefaults.dataStack.fetchAll(from, fetchClauses)
}
/**
Fetches all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
```
- let people = CoreStore.fetchAll(
+ let people = dataStack.fetchAll(
From()
.where(\.age > 18)
.orderBy(.ascending(\.age))
@@ -161,11 +161,11 @@ extension CoreStore {
*/
public static func fetchAll(_ clauseChain: B) throws -> [B.ObjectType] {
- return try Shared.defaultStack.fetchAll(clauseChain)
+ return try CoreStoreDefaults.dataStack.fetchAll(clauseChain)
}
/**
- Using the `defaultStack`, fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -174,11 +174,11 @@ extension CoreStore {
*/
public static func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int {
- return try Shared.defaultStack.fetchCount(from, fetchClauses)
+ return try CoreStoreDefaults.dataStack.fetchCount(from, fetchClauses)
}
/**
- Using the `defaultStack`, fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -187,13 +187,13 @@ extension CoreStore {
*/
public static func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int {
- return try Shared.defaultStack.fetchCount(from, fetchClauses)
+ return try CoreStoreDefaults.dataStack.fetchCount(from, fetchClauses)
}
/**
Fetches the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
```
- let numberOfAdults = CoreStore.fetchCount(
+ let numberOfAdults = dataStack.fetchCount(
From()
.where(\.age > 18)
.orderBy(.ascending(\.age))
@@ -205,11 +205,11 @@ extension CoreStore {
*/
public static func fetchCount(_ clauseChain: B) throws -> Int {
- return try Shared.defaultStack.fetchCount(clauseChain)
+ return try CoreStoreDefaults.dataStack.fetchCount(clauseChain)
}
/**
- Using the `defaultStack`, fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -218,11 +218,11 @@ extension CoreStore {
*/
public static func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
- return try Shared.defaultStack.fetchObjectID(from, fetchClauses)
+ return try CoreStoreDefaults.dataStack.fetchObjectID(from, fetchClauses)
}
/**
- Using the `defaultStack`, fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -231,13 +231,13 @@ extension CoreStore {
*/
public static func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
- return try Shared.defaultStack.fetchObjectID(from, fetchClauses)
+ return try CoreStoreDefaults.dataStack.fetchObjectID(from, fetchClauses)
}
/**
Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType` built from a chain of clauses.
```
- let youngestTeenID = CoreStore.fetchObjectID(
+ let youngestTeenID = dataStack.fetchObjectID(
From()
.where(\.age > 18)
.orderBy(.ascending(\.age))
@@ -249,11 +249,11 @@ extension CoreStore {
*/
public static func fetchObjectID(_ clauseChain: B) throws -> NSManagedObjectID? {
- return try Shared.defaultStack.fetchObjectID(clauseChain)
+ return try CoreStoreDefaults.dataStack.fetchObjectID(clauseChain)
}
/**
- Using the `defaultStack`, fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -262,11 +262,11 @@ extension CoreStore {
*/
public static func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
- return try Shared.defaultStack.fetchObjectIDs(from, fetchClauses)
+ return try CoreStoreDefaults.dataStack.fetchObjectIDs(from, fetchClauses)
}
/**
- Using the `defaultStack`, fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -275,7 +275,7 @@ extension CoreStore {
*/
public static func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
- return try Shared.defaultStack.fetchObjectIDs(from, fetchClauses)
+ return try CoreStoreDefaults.dataStack.fetchObjectIDs(from, fetchClauses)
}
/**
@@ -293,11 +293,11 @@ extension CoreStore {
*/
public static func fetchObjectIDs(_ clauseChain: B) throws -> [NSManagedObjectID] {
- return try Shared.defaultStack.fetchObjectIDs(clauseChain)
+ return try CoreStoreDefaults.dataStack.fetchObjectIDs(clauseChain)
}
/**
- Using the `defaultStack`, queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
A "query" differs from a "fetch" in that it only retrieves values already stored in the persistent store. As such, values from unsaved transactions or contexts will not be incorporated in the query result.
@@ -309,11 +309,11 @@ extension CoreStore {
*/
public static func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? {
- return try Shared.defaultStack.queryValue(from, selectClause, queryClauses)
+ return try CoreStoreDefaults.dataStack.queryValue(from, selectClause, queryClauses)
}
/**
- Using the `defaultStack`, queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
A "query" differs from a "fetch" in that it only retrieves values already stored in the persistent store. As such, values from unsaved transactions or contexts will not be incorporated in the query result.
@@ -325,7 +325,7 @@ extension CoreStore {
*/
public static func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? {
- return try Shared.defaultStack.queryValue(from, selectClause, queryClauses)
+ return try CoreStoreDefaults.dataStack.queryValue(from, selectClause, queryClauses)
}
/**
@@ -333,7 +333,7 @@ extension CoreStore {
A "query" differs from a "fetch" in that it only retrieves values already stored in the persistent store. As such, values from unsaved transactions or contexts will not be incorporated in the query result.
```
- let averageAdultAge = CoreStore.queryValue(
+ let averageAdultAge = dataStack.queryValue(
From()
.select(Int.self, .average(\.age))
.where(\.age > 18)
@@ -345,11 +345,11 @@ extension CoreStore {
*/
public static func queryValue(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType {
- return try Shared.defaultStack.queryValue(clauseChain)
+ return try CoreStoreDefaults.dataStack.queryValue(clauseChain)
}
/**
- Using the `defaultStack`, queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
A "query" differs from a "fetch" in that it only retrieves values already stored in the persistent store. As such, values from unsaved transactions or contexts will not be incorporated in the query result.
@@ -361,11 +361,11 @@ extension CoreStore {
*/
public static func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
- return try Shared.defaultStack.queryAttributes(from, selectClause, queryClauses)
+ return try CoreStoreDefaults.dataStack.queryAttributes(from, selectClause, queryClauses)
}
/**
- Using the `defaultStack`, queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
+ Using the `CoreStoreDefaults.dataStack`, queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
A "query" differs from a "fetch" in that it only retrieves values already stored in the persistent store. As such, values from unsaved transactions or contexts will not be incorporated in the query result.
@@ -377,7 +377,7 @@ extension CoreStore {
*/
public static func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
- return try Shared.defaultStack.queryAttributes(from, selectClause, queryClauses)
+ return try CoreStoreDefaults.dataStack.queryAttributes(from, selectClause, queryClauses)
}
/**
@@ -385,7 +385,7 @@ extension CoreStore {
A "query" differs from a "fetch" in that it only retrieves values already stored in the persistent store. As such, values from unsaved transactions or contexts will not be incorporated in the query result.
```
- let results = CoreStore.queryAttributes(
+ let results = dataStack.queryAttributes(
From()
.select(
NSDictionary.self,
@@ -406,6 +406,6 @@ extension CoreStore {
*/
public static func queryAttributes(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary {
- return try Shared.defaultStack.queryAttributes(clauseChain)
+ return try CoreStoreDefaults.dataStack.queryAttributes(clauseChain)
}
}
diff --git a/Sources/CoreStore+Setup.swift b/Sources/CoreStore+Setup.swift
index af45f8b..4db95f0 100644
--- a/Sources/CoreStore+Setup.swift
+++ b/Sources/CoreStore+Setup.swift
@@ -33,90 +33,90 @@ import CoreData
extension CoreStore {
/**
- Returns the `defaultStack`'s model version. The version string is the same as the name of a version-specific .xcdatamodeld file or `CoreStoreSchema`.
+ Returns the `CoreStoreDefaults.dataStack`'s model version. The version string is the same as the name of a version-specific .xcdatamodeld file or `CoreStoreSchema`.
*/
public static var modelVersion: String {
- return Shared.defaultStack.modelVersion
+ return CoreStoreDefaults.dataStack.modelVersion
}
/**
- Returns the entity name-to-class type mapping from the `defaultStack`'s model.
+ Returns the entity name-to-class type mapping from the `CoreStoreDefaults.dataStack`'s model.
*/
public static func entityTypesByName(for type: NSManagedObject.Type) -> [EntityName: NSManagedObject.Type] {
- return Shared.defaultStack.entityTypesByName(for: type)
+ return CoreStoreDefaults.dataStack.entityTypesByName(for: type)
}
/**
- Returns the entity name-to-class type mapping from the `defaultStack`'s model.
+ Returns the entity name-to-class type mapping from the `CoreStoreDefaults.dataStack`'s model.
*/
public static func entityTypesByName(for type: CoreStoreObject.Type) -> [EntityName: CoreStoreObject.Type] {
- return Shared.defaultStack.entityTypesByName(for: type)
+ return CoreStoreDefaults.dataStack.entityTypesByName(for: type)
}
/**
- Returns the `NSEntityDescription` for the specified `NSManagedObject` subclass from `defaultStack`'s model.
+ Returns the `NSEntityDescription` for the specified `NSManagedObject` subclass from `CoreStoreDefaults.dataStack`'s model.
*/
public static func entityDescription(for type: NSManagedObject.Type) -> NSEntityDescription? {
- return Shared.defaultStack.entityDescription(for: type)
+ return CoreStoreDefaults.dataStack.entityDescription(for: type)
}
/**
- Returns the `NSEntityDescription` for the specified `CoreStoreObject` subclass from `defaultStack`'s model.
+ Returns the `NSEntityDescription` for the specified `CoreStoreObject` subclass from `CoreStoreDefaults.dataStack`'s model.
*/
public static func entityDescription(for type: CoreStoreObject.Type) -> NSEntityDescription? {
- return Shared.defaultStack.entityDescription(for: type)
+ return CoreStoreDefaults.dataStack.entityDescription(for: type)
}
/**
- Creates an `SQLiteStore` with default parameters and adds it to the `defaultStack`. This method blocks until completion.
+ Creates an `SQLiteStore` with default parameters and adds it to the `CoreStoreDefaults.dataStack`. This method blocks until completion.
```
try CoreStore.addStorageAndWait()
```
- - returns: the local SQLite storage added to the `defaultStack`
+ - returns: the local SQLite storage added to the `CoreStoreDefaults.dataStack`
*/
@discardableResult
public static func addStorageAndWait() throws -> SQLiteStore {
- return try Shared.defaultStack.addStorageAndWait(SQLiteStore())
+ return try CoreStoreDefaults.dataStack.addStorageAndWait(SQLiteStore())
}
/**
- Adds a `StorageInterface` to the `defaultStack` and blocks until completion.
+ Adds a `StorageInterface` to the `CoreStoreDefaults.dataStack` and blocks until completion.
```
try CoreStore.addStorageAndWait(InMemoryStore(configuration: "Config1"))
```
- parameter storage: the `StorageInterface`
- throws: a `CoreStoreError` value indicating the failure
- - returns: the `StorageInterface` added to the `defaultStack`
+ - returns: the `StorageInterface` added to the `CoreStoreDefaults.dataStack`
*/
@discardableResult
public static func addStorageAndWait(_ storage: T) throws -> T {
- return try Shared.defaultStack.addStorageAndWait(storage)
+ return try CoreStoreDefaults.dataStack.addStorageAndWait(storage)
}
/**
- Adds a `LocalStorage` to the `defaultStack` and blocks until completion.
+ Adds a `LocalStorage` to the `CoreStoreDefaults.dataStack` and blocks until completion.
```
try CoreStore.addStorageAndWait(SQLiteStore(configuration: "Config1"))
```
- parameter storage: the local storage
- throws: a `CoreStoreError` value indicating the failure
- - returns: the local storage added to the `defaultStack`. Note that this 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: the local storage added to the `CoreStoreDefaults.dataStack`. Note that this 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.
*/
@discardableResult
public static func addStorageAndWait(_ storage: T) throws -> T {
- return try Shared.defaultStack.addStorageAndWait(storage)
+ return try CoreStoreDefaults.dataStack.addStorageAndWait(storage)
}
/**
- Adds a `CloudStorage` to the `defaultStack` and blocks until completion.
+ Adds a `CloudStorage` to the `CoreStoreDefaults.dataStack` and blocks until completion.
```
guard let storage = ICloudStore(
ubiquitousContentName: "MyAppCloudData",
@@ -138,6 +138,6 @@ extension CoreStore {
@discardableResult
public static func addStorageAndWait(_ storage: T) throws -> T {
- return try Shared.defaultStack.addStorageAndWait(storage)
+ return try CoreStoreDefaults.dataStack.addStorageAndWait(storage)
}
}
diff --git a/Sources/CoreStore+Transaction.swift b/Sources/CoreStore+Transaction.swift
index 8381ce0..c0a7052 100644
--- a/Sources/CoreStore+Transaction.swift
+++ b/Sources/CoreStore+Transaction.swift
@@ -32,18 +32,18 @@ import Foundation
extension CoreStore {
/**
- Using the `defaultStack`, performs a transaction asynchronously where `NSManagedObject` or `CoreStoreObject` creates, updates, and deletes can be made. The changes are commited automatically after the `task` closure returns. On success, the value returned from closure will be the wrapped as `.success(T)` in the `completion`'s `Result`. Any errors thrown from inside the `task` will be reported as `.failure(CoreStoreError)`. To cancel/rollback changes, call `try transaction.cancel()`, which throws a `CoreStoreError.userCancelled`.
+ Using the `CoreStoreDefaults.dataStack`, performs a transaction asynchronously where `NSManagedObject` or `CoreStoreObject` creates, updates, and deletes can be made. The changes are commited automatically after the `task` closure returns. On success, the value returned from closure will be the wrapped as `.success(T)` in the `completion`'s `Result`. Any errors thrown from inside the `task` will be reported as `.failure(CoreStoreError)`. To cancel/rollback changes, call `try transaction.cancel()`, which throws a `CoreStoreError.userCancelled`.
- parameter task: the asynchronous closure where creates, updates, and deletes can be made to the transaction. Transaction blocks are executed serially in a background queue, and all changes are made from a concurrent `NSManagedObjectContext`.
- parameter completion: the closure executed after the save completes. The `Result` argument of the closure will either wrap the return value of `task`, or any uncaught errors thrown from within `task`. Cancelled `task`s will be indicated by `.failure(error: CoreStoreError.userCancelled)`. Custom errors thrown by the user will be wrapped in `CoreStoreError.userError(error: Error)`.
*/
public static func perform(asynchronous task: @escaping (_ transaction: AsynchronousDataTransaction) throws -> T, completion: @escaping (AsynchronousDataTransaction.Result) -> Void) {
- Shared.defaultStack.perform(asynchronous: task, completion: completion)
+ CoreStoreDefaults.dataStack.perform(asynchronous: task, completion: completion)
}
/**
- Using the `defaultStack`, performs a transaction asynchronously where `NSManagedObject` or `CoreStoreObject` creates, updates, and deletes can be made. The changes are commited automatically after the `task` closure returns. On success, the value returned from closure will be the argument of the `success` closure. Any errors thrown from inside the `task` will be wrapped in a `CoreStoreError` and reported in the `failure` closure. To cancel/rollback changes, call `try transaction.cancel()`, which throws a `CoreStoreError.userCancelled`.
+ Using the `CoreStoreDefaults.dataStack`, performs a transaction asynchronously where `NSManagedObject` or `CoreStoreObject` creates, updates, and deletes can be made. The changes are commited automatically after the `task` closure returns. On success, the value returned from closure will be the argument of the `success` closure. Any errors thrown from inside the `task` will be wrapped in a `CoreStoreError` and reported in the `failure` closure. To cancel/rollback changes, call `try transaction.cancel()`, which throws a `CoreStoreError.userCancelled`.
- parameter task: the asynchronous closure where creates, updates, and deletes can be made to the transaction. Transaction blocks are executed serially in a background queue, and all changes are made from a concurrent `NSManagedObjectContext`.
- parameter success: the closure executed after the save succeeds. The `T` argument of the closure will be the value returned from `task`.
@@ -51,11 +51,11 @@ extension CoreStore {
*/
public static func perform(asynchronous task: @escaping (_ transaction: AsynchronousDataTransaction) throws -> T, success: @escaping (T) -> Void, failure: @escaping (CoreStoreError) -> Void) {
- Shared.defaultStack.perform(asynchronous: task, success: success, failure: failure)
+ CoreStoreDefaults.dataStack.perform(asynchronous: task, success: success, failure: failure)
}
/**
- Using the `defaultStack`, performs a transaction synchronously where `NSManagedObject` or `CoreStoreObject` creates, updates, and deletes can be made. The changes are commited automatically after the `task` closure returns. On success, the value returned from closure will be the return value of `perform(synchronous:)`. Any errors thrown from inside the `task` will be thrown from `perform(synchronous:)`. To cancel/rollback changes, call `try transaction.cancel()`, which throws a `CoreStoreError.userCancelled`.
+ Using the `CoreStoreDefaults.dataStack`, performs a transaction synchronously where `NSManagedObject` or `CoreStoreObject` creates, updates, and deletes can be made. The changes are commited automatically after the `task` closure returns. On success, the value returned from closure will be the return value of `perform(synchronous:)`. Any errors thrown from inside the `task` will be thrown from `perform(synchronous:)`. To cancel/rollback changes, call `try transaction.cancel()`, which throws a `CoreStoreError.userCancelled`.
- parameter task: the synchronous non-escaping closure where creates, updates, and deletes can be made to the transaction. Transaction blocks are executed serially in a background queue, and all changes are made from a concurrent `NSManagedObjectContext`.
- parameter waitForAllObservers: When `true`, this method waits for all observers to be notified of the changes before returning. This results in more predictable data update order, but may risk triggering deadlocks. When `false`, this method does not wait for observers to be notified of the changes before returning. This results in lower risk for deadlocks, but the updated data may not have been propagated to the `DataStack` after returning. Defaults to `true`.
@@ -64,25 +64,25 @@ extension CoreStore {
*/
public static func perform(synchronous task: ((_ transaction: SynchronousDataTransaction) throws -> T), waitForAllObservers: Bool = true) throws -> T {
- return try Shared.defaultStack.perform(synchronous: task, waitForAllObservers: waitForAllObservers)
+ return try CoreStoreDefaults.dataStack.perform(synchronous: task, waitForAllObservers: waitForAllObservers)
}
/**
- Using the `defaultStack`, begins a non-contiguous transaction where `NSManagedObject` or `CoreStoreObject` creates, updates, and deletes can be made. This is useful for making temporary changes, such as partially filled forms.
+ Using the `CoreStoreDefaults.dataStack`, begins a non-contiguous transaction where `NSManagedObject` or `CoreStoreObject` creates, updates, and deletes can be made. This is useful for making temporary changes, such as partially filled forms.
- prameter supportsUndo: `undo()`, `redo()`, and `rollback()` methods are only available when this parameter is `true`, otherwise those method will raise an exception. Defaults to `false`. Note that turning on Undo support may heavily impact performance especially on iOS or watchOS where memory is limited.
- returns: a `UnsafeDataTransaction` instance where creates, updates, and deletes can be made.
*/
public static func beginUnsafe(supportsUndo: Bool = false) -> UnsafeDataTransaction {
- return Shared.defaultStack.beginUnsafe(supportsUndo: supportsUndo)
+ return CoreStoreDefaults.dataStack.beginUnsafe(supportsUndo: supportsUndo)
}
/**
- Refreshes all registered objects `NSManagedObject`s or `CoreStoreObject`s in the `defaultStack`.
+ Refreshes all registered objects `NSManagedObject`s or `CoreStoreObject`s in the `CoreStoreDefaults.dataStack`.
*/
public static func refreshAndMergeAllObjects() {
- Shared.defaultStack.refreshAndMergeAllObjects()
+ CoreStoreDefaults.dataStack.refreshAndMergeAllObjects()
}
}
diff --git a/Sources/CoreStore.swift b/Sources/CoreStore.swift
index d42ed7f..77f975a 100644
--- a/Sources/CoreStore.swift
+++ b/Sources/CoreStore.swift
@@ -34,17 +34,17 @@ import CoreData
@available(*, deprecated, message: "Call methods directly from the DataStack instead")
public enum CoreStore {
- @available(*, unavailable, renamed: "Shared.logger")
+ @available(*, unavailable, renamed: "CoreStoreDefaults.logger")
public static var logger: CoreStoreLogger {
- get { return Shared.logger }
- set { Shared.logger = newValue }
+ get { return CoreStoreDefaults.logger }
+ set { CoreStoreDefaults.logger = newValue }
}
- @available(*, unavailable, renamed: "Shared.defaultStack")
+ @available(*, unavailable, renamed: "CoreStoreDefaults.dataStack")
public static var defaultStack: DataStack {
- get { return Shared.defaultStack }
- set { Shared.defaultStack = newValue }
+ get { return CoreStoreDefaults.dataStack }
+ set { CoreStoreDefaults.dataStack = newValue }
}
}
diff --git a/Sources/Shared.swift b/Sources/CoreStoreDefaults.swift
similarity index 77%
rename from Sources/Shared.swift
rename to Sources/CoreStoreDefaults.swift
index 8810826..966d4f5 100644
--- a/Sources/Shared.swift
+++ b/Sources/CoreStoreDefaults.swift
@@ -1,5 +1,5 @@
//
-// Shared.swift
+// CoreStoreDefaults.swift
// CoreStore
//
// Copyright © 2018 John Rommel Estropia
@@ -26,19 +26,25 @@
import Foundation
-// MARK: - Shared
+// MARK: - CoreStoreDefaults
/**
Global utilities
*/
-public enum Shared {
+public enum CoreStoreDefaults {
/**
The `CoreStoreLogger` instance to be used. The default logger is an instance of a `DefaultLogger`.
*/
public static var logger: CoreStoreLogger = DefaultLogger()
-
- public static var defaultStack: DataStack {
+
+ /**
+ The default `DataStack` instance to be used. If `defaultStack` is not set during the first time accessed, a default-configured `DataStack` will be created.
+ - SeeAlso: `DataStack`
+ - Note: Changing `dataStack` is thread safe, but it is recommended to setup `DataStacks` on a common queue (e.g. the main queue).
+ - Important: If `dataStack` is not set during the first time accessed, a default-configured `DataStack` will be created.
+ */
+ public static var dataStack: DataStack {
get {
diff --git a/Sources/CoreStoreLogger.swift b/Sources/CoreStoreLogger.swift
index 6bec546..fc28fe9 100644
--- a/Sources/CoreStoreLogger.swift
+++ b/Sources/CoreStoreLogger.swift
@@ -43,7 +43,7 @@ public enum LogLevel {
// MARK: - CoreStoreLogger
/**
- Custom loggers should implement the `CoreStoreLogger` protocol and pass its instance to `CoreStore.logger`. Calls to `log(...)`, `assert(...)`, and `abort(...)` are not tied to a specific queue/thread, so it is the implementer's job to handle thread-safety.
+ Custom loggers should implement the `CoreStoreLogger` protocol and pass its instance to `CoreStoreDefaults.logger`. Calls to `log(...)`, `assert(...)`, and `abort(...)` are not tied to a specific queue/thread, so it is the implementer's job to handle thread-safety.
*/
public protocol CoreStoreLogger {
diff --git a/Sources/CoreStoreObject+Querying.swift b/Sources/CoreStoreObject+Querying.swift
index dc9d94d..8d21e91 100644
--- a/Sources/CoreStoreObject+Querying.swift
+++ b/Sources/CoreStoreObject+Querying.swift
@@ -33,7 +33,7 @@ extension ValueContainer.Required {
/**
Creates a `Where` clause by comparing if a property is equal to a value
```
- let person = CoreStore.fetchOne(From().where({ $0.nickname == "John" }))
+ let person = dataStack.fetchOne(From().where({ $0.nickname == "John" }))
```
*/
public static func == (_ attribute: ValueContainer.Required, _ value: V) -> Where {
@@ -44,7 +44,7 @@ extension ValueContainer.Required {
/**
Creates a `Where` clause by comparing if a property is not equal to a value
```
- let person = CoreStore.fetchOne(From().where({ $0.nickname != "John" }))
+ let person = dataStack.fetchOne(From().where({ $0.nickname != "John" }))
```
*/
public static func != (_ attribute: ValueContainer.Required, _ value: V) -> Where {
@@ -55,7 +55,7 @@ extension ValueContainer.Required {
/**
Creates a `Where` clause by comparing if a property is less than a value
```
- let person = CoreStore.fetchOne(From().where({ $0.age < 20 }))
+ let person = dataStack.fetchOne(From().where({ $0.age < 20 }))
```
*/
public static func < (_ attribute: ValueContainer.Required, _ value: V) -> Where {
@@ -66,7 +66,7 @@ extension ValueContainer.Required {
/**
Creates a `Where` clause by comparing if a property is greater than a value
```
- let person = CoreStore.fetchOne(From().where({ $0.age > 20 }))
+ let person = dataStack.fetchOne(From().where({ $0.age > 20 }))
```
*/
public static func > (_ attribute: ValueContainer.Required, _ value: V) -> Where {
@@ -77,7 +77,7 @@ extension ValueContainer.Required {
/**
Creates a `Where` clause by comparing if a property is less than or equal to a value
```
- let person = CoreStore.fetchOne(From().where({ $0.age <= 20 }))
+ let person = dataStack.fetchOne(From().where({ $0.age <= 20 }))
```
*/
public static func <= (_ attribute: ValueContainer.Required, _ value: V) -> Where {
@@ -88,7 +88,7 @@ extension ValueContainer.Required {
/**
Creates a `Where` clause by comparing if a property is greater than or equal to a value
```
- let person = CoreStore.fetchOne(From().where({ $0.age >= 20 }))
+ let person = dataStack.fetchOne(From().where({ $0.age >= 20 }))
```
*/
public static func >= (_ attribute: ValueContainer.Required, _ value: V) -> Where {
@@ -99,7 +99,7 @@ extension ValueContainer.Required {
/**
Creates a `Where` clause by checking if a sequence contains the value of a property
```
- let dog = CoreStore.fetchOne(From().where({ ["Pluto", "Snoopy", "Scooby"] ~= $0.nickname }))
+ let dog = dataStack.fetchOne(From().where({ ["Pluto", "Snoopy", "Scooby"] ~= $0.nickname }))
```
*/
public static func ~= (_ sequence: S, _ attribute: ValueContainer.Required) -> Where where S.Iterator.Element == V {
@@ -116,7 +116,7 @@ extension ValueContainer.Optional {
/**
Creates a `Where` clause by comparing if a property is equal to a value
```
- let person = CoreStore.fetchOne(From().where({ $0.nickname == "John" }))
+ let person = dataStack.fetchOne(From().where({ $0.nickname == "John" }))
```
*/
public static func == (_ attribute: ValueContainer.Optional, _ value: V?) -> Where {
@@ -127,7 +127,7 @@ extension ValueContainer.Optional {
/**
Creates a `Where` clause by comparing if a property is not equal to a value
```
- let person = CoreStore.fetchOne(From().where({ $0.nickname != "John" }))
+ let person = dataStack.fetchOne(From().where({ $0.nickname != "John" }))
```
*/
public static func != (_ attribute: ValueContainer.Optional, _ value: V?) -> Where {
@@ -138,7 +138,7 @@ extension ValueContainer.Optional {
/**
Creates a `Where` clause by comparing if a property is less than a value
```
- let person = CoreStore.fetchOne(From().where({ $0.age < 20 }))
+ let person = dataStack.fetchOne(From().where({ $0.age < 20 }))
```
*/
public static func < (_ attribute: ValueContainer.Optional, _ value: V?) -> Where {
@@ -156,7 +156,7 @@ extension ValueContainer.Optional {
/**
Creates a `Where` clause by comparing if a property is greater than a value
```
- let person = CoreStore.fetchOne(From().where({ $0.age > 20 }))
+ let person = dataStack.fetchOne(From().where({ $0.age > 20 }))
```
*/
public static func > (_ attribute: ValueContainer.Optional, _ value: V?) -> Where {
@@ -174,7 +174,7 @@ extension ValueContainer.Optional {
/**
Creates a `Where` clause by comparing if a property is less than or equal to a value
```
- let person = CoreStore.fetchOne(From().where({ $0.age <= 20 }))
+ let person = dataStack.fetchOne(From().where({ $0.age <= 20 }))
```
*/
public static func <= (_ attribute: ValueContainer.Optional, _ value: V?) -> Where {
@@ -192,7 +192,7 @@ extension ValueContainer.Optional {
/**
Creates a `Where` clause by comparing if a property is greater than or equal to a value
```
- let person = CoreStore.fetchOne(From().where({ $0.age >= 20 }))
+ let person = dataStack.fetchOne(From().where({ $0.age >= 20 }))
```
*/
public static func >= (_ attribute: ValueContainer.Optional, _ value: V?) -> Where {
@@ -210,7 +210,7 @@ extension ValueContainer.Optional {
/**
Creates a `Where` clause by checking if a sequence contains the value of a property
```
- let dog = CoreStore.fetchOne(From().where({ ["Pluto", "Snoopy", "Scooby"] ~= $0.nickname }))
+ let dog = dataStack.fetchOne(From().where({ ["Pluto", "Snoopy", "Scooby"] ~= $0.nickname }))
```
*/
public static func ~= (_ sequence: S, _ attribute: ValueContainer.Optional) -> Where where S.Iterator.Element == V {
@@ -227,7 +227,7 @@ extension RelationshipContainer.ToOne {
/**
Creates a `Where` clause by comparing if a property is equal to a value
```
- let dog = CoreStore.fetchOne(From().where({ $0.master == me }))
+ let dog = dataStack.fetchOne(From().where({ $0.master == me }))
```
*/
public static func == (_ relationship: RelationshipContainer.ToOne, _ object: D?) -> Where {
@@ -238,7 +238,7 @@ extension RelationshipContainer.ToOne {
/**
Creates a `Where` clause by comparing if a property is not equal to a value
```
- let dog = CoreStore.fetchOne(From().where({ $0.master != me }))
+ let dog = dataStack.fetchOne(From().where({ $0.master != me }))
```
*/
public static func != (_ relationship: RelationshipContainer.ToOne, _ object: D?) -> Where {
@@ -249,7 +249,7 @@ extension RelationshipContainer.ToOne {
/**
Creates a `Where` clause by checking if a sequence contains the value of a property
```
- let dog = CoreStore.fetchOne(From().where({ [john, joe, bob] ~= $0.master }))
+ let dog = dataStack.fetchOne(From().where({ [john, joe, bob] ~= $0.master }))
```
*/
public static func ~= (_ sequence: S, _ relationship: RelationshipContainer