Docs update

This commit is contained in:
John Estropia
2019-10-20 18:17:31 +09:00
parent a267395618
commit f5fed063ee
56 changed files with 853 additions and 863 deletions

View File

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

View File

@@ -1,7 +1,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "CoreStore" s.name = "CoreStore"
s.version = "6.3.2" s.version = "7.0.0"
s.swift_version = "5.0" s.swift_version = "5.1"
s.license = "MIT" s.license = "MIT"
s.homepage = "https://github.com/JohnEstropia/CoreStore" s.homepage = "https://github.com/JohnEstropia/CoreStore"
s.documentation_url = "https://JohnEstropia.github.io/CoreStore" s.documentation_url = "https://JohnEstropia.github.io/CoreStore"

View File

@@ -465,10 +465,10 @@
B56321B31BD6521C006C9394 /* NSManagedObjectContext+Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F321AFF85470064E85B /* NSManagedObjectContext+Setup.swift */; }; 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 */; }; 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 */; }; 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 */; }; B5635D142356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift */; };
B5635D152356C39500B80E6B /* DiffableDataSource.CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView.swift */; }; B5635D152356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift */; };
B5635D162356C39500B80E6B /* DiffableDataSource.CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView.swift */; }; B5635D162356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift */; };
B5635D172356C39500B80E6B /* DiffableDataSource.CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView.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 */; }; B56507941D3930BC000596DA /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507931D3930BC000596DA /* CoreData.framework */; };
B56507961D3930C1000596DA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507951D3930C1000596DA /* Foundation.framework */; }; B56507961D3930C1000596DA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507951D3930C1000596DA /* Foundation.framework */; };
B56507981D3930CC000596DA /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507971D3930CC000596DA /* CoreData.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 */; }; B5A992201EA898720091A2E3 /* UserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5A9921E1EA898710091A2E3 /* UserInfo.swift */; };
B5A992211EA898720091A2E3 /* 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 */; }; 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 */; }; B5AEFAB51C9962AE00AD137F /* CoreStoreBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AEFAB41C9962AE00AD137F /* CoreStoreBridge.swift */; };
B5AEFAB61C9962AE00AD137F /* 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 */; }; 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 */; }; B5BF7FB3234C97910070E741 /* DiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB1234C97910070E741 /* DiffableDataSource.swift */; };
B5BF7FB4234C97910070E741 /* 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 */; }; B5BF7FB5234C97910070E741 /* DiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB1234C97910070E741 /* DiffableDataSource.swift */; };
B5BF7FB7234C97CE0070E741 /* 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.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView.swift */; }; B5BF7FB8234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift */; };
B5BF7FB9234C97CE0070E741 /* DiffableDataSource.TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView.swift */; }; B5BF7FB9234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift */; };
B5BF7FBA234C97CE0070E741 /* DiffableDataSource.TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView.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 */; }; 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 */; }; 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 */; }; 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 */; }; B5DE522C230BD7D500A22534 /* Internals.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522A230BD7CC00A22534 /* Internals.swift */; };
B5DE522D230BD7D600A22534 /* 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 */; }; B5DE522E230BD7D600A22534 /* Internals.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522A230BD7CC00A22534 /* Internals.swift */; };
B5DE5230230BDA1300A22534 /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* Shared.swift */; }; B5DE5230230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* CoreStoreDefaults.swift */; };
B5DE5231230BDA1300A22534 /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* Shared.swift */; }; B5DE5231230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* CoreStoreDefaults.swift */; };
B5DE5232230BDA1300A22534 /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* Shared.swift */; }; B5DE5232230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* CoreStoreDefaults.swift */; };
B5DE5233230BDA1300A22534 /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* Shared.swift */; }; B5DE5233230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DE522F230BDA1300A22534 /* CoreStoreDefaults.swift */; };
B5E1B5931CAA0C15007FD580 /* CSObjectMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E1B5921CAA0C15007FD580 /* CSObjectMonitor.swift */; }; B5E1B5931CAA0C15007FD580 /* CSObjectMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E1B5921CAA0C15007FD580 /* CSObjectMonitor.swift */; };
B5E1B5951CAA0C15007FD580 /* 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 */; }; 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; }; 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; }; 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; }; 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 = "<group>"; }; B50132292344ECB500FC238B /* ListPublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPublisher.swift; sourceTree = "<group>"; };
B501322F2346B76E00FC238B /* Internals.FetchedDiffableDataSourceSnapshotDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Internals.FetchedDiffableDataSourceSnapshotDelegate.swift; sourceTree = "<group>"; }; B501322F2346B76E00FC238B /* Internals.FetchedDiffableDataSourceSnapshotDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Internals.FetchedDiffableDataSourceSnapshotDelegate.swift; sourceTree = "<group>"; };
B501323623477F9300FC238B /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/SwiftUI.framework; sourceTree = DEVELOPER_DIR; }; B501323623477F9300FC238B /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/SwiftUI.framework; sourceTree = DEVELOPER_DIR; };
@@ -969,7 +973,7 @@
B563216F1BD65082006C9394 /* CoreStore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CoreStore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B563216F1BD65082006C9394 /* CoreStore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CoreStore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B56321791BD650DE006C9394 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.0.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; }; B56321791BD650DE006C9394 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.0.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; };
B563217B1BD650E3006C9394 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; B563217B1BD650E3006C9394 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiffableDataSource.CollectionView.swift; sourceTree = "<group>"; }; B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DiffableDataSource.CollectionView-UIKit.swift"; sourceTree = "<group>"; };
B56507931D3930BC000596DA /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.0.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; }; B56507931D3930BC000596DA /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.0.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; };
B56507951D3930C1000596DA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; B56507951D3930C1000596DA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
B56507971D3930CC000596DA /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; }; B56507971D3930CC000596DA /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; };
@@ -1006,12 +1010,14 @@
B5A80DF52212C1BC006096AA /* Playground_iOS.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Playground_iOS.playground; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; B5A80DF52212C1BC006096AA /* Playground_iOS.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Playground_iOS.playground; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
B5A991EB1E9DC2CE0091A2E3 /* VersionLock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VersionLock.swift; sourceTree = "<group>"; }; B5A991EB1E9DC2CE0091A2E3 /* VersionLock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VersionLock.swift; sourceTree = "<group>"; };
B5A9921E1EA898710091A2E3 /* UserInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserInfo.swift; sourceTree = "<group>"; }; B5A9921E1EA898710091A2E3 /* UserInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserInfo.swift; sourceTree = "<group>"; };
B5AA37F0235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "diffableDataSource.CollectionView-AppKit.swift"; sourceTree = "<group>"; };
B5AA37FA235C3D1300FFD4B9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS6.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
B5AA37FC235C3D1A00FFD4B9 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS6.0.sdk/System/Library/Frameworks/SwiftUI.framework; sourceTree = DEVELOPER_DIR; };
B5AD60CD1C90141E00F2B2E8 /* Package.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = SOURCE_ROOT; }; B5AD60CD1C90141E00F2B2E8 /* Package.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = SOURCE_ROOT; };
B5AEFAB41C9962AE00AD137F /* CoreStoreBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreBridge.swift; sourceTree = "<group>"; }; B5AEFAB41C9962AE00AD137F /* CoreStoreBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreBridge.swift; sourceTree = "<group>"; };
B5BDC9271C2024F2008147CD /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .travis.yml; sourceTree = SOURCE_ROOT; };
B5BF7FAC234C41E90070E741 /* Internals.DiffableDataSourceSnapshot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Internals.DiffableDataSourceSnapshot.swift; sourceTree = "<group>"; }; B5BF7FAC234C41E90070E741 /* Internals.DiffableDataSourceSnapshot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Internals.DiffableDataSourceSnapshot.swift; sourceTree = "<group>"; };
B5BF7FB1234C97910070E741 /* DiffableDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiffableDataSource.swift; sourceTree = "<group>"; }; B5BF7FB1234C97910070E741 /* DiffableDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiffableDataSource.swift; sourceTree = "<group>"; };
B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiffableDataSource.TableView.swift; sourceTree = "<group>"; }; B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DiffableDataSource.TableView-UIKit.swift"; sourceTree = "<group>"; };
B5BF7FBB234C99190070E741 /* Internals.DiffableDataUIDispatcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Internals.DiffableDataUIDispatcher.swift; sourceTree = "<group>"; }; B5BF7FBB234C99190070E741 /* Internals.DiffableDataUIDispatcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Internals.DiffableDataUIDispatcher.swift; sourceTree = "<group>"; };
B5BF7FC0234D7B2E0070E741 /* ObjectPublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectPublisher.swift; sourceTree = "<group>"; }; B5BF7FC0234D7B2E0070E741 /* ObjectPublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectPublisher.swift; sourceTree = "<group>"; };
B5BF7FC5234D7E460070E741 /* ObjectSnapshot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectSnapshot.swift; sourceTree = "<group>"; }; B5BF7FC5234D7E460070E741 /* ObjectSnapshot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectSnapshot.swift; sourceTree = "<group>"; };
@@ -1046,7 +1052,7 @@
B5DC47C51C93D22900FA3BF3 /* MigrationChainTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MigrationChainTests.swift; sourceTree = "<group>"; }; B5DC47C51C93D22900FA3BF3 /* MigrationChainTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MigrationChainTests.swift; sourceTree = "<group>"; };
B5DC47C91C93D9C800FA3BF3 /* StorageInterfaceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageInterfaceTests.swift; sourceTree = "<group>"; }; B5DC47C91C93D9C800FA3BF3 /* StorageInterfaceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageInterfaceTests.swift; sourceTree = "<group>"; };
B5DE522A230BD7CC00A22534 /* Internals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Internals.swift; sourceTree = "<group>"; }; B5DE522A230BD7CC00A22534 /* Internals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Internals.swift; sourceTree = "<group>"; };
B5DE522F230BDA1300A22534 /* Shared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shared.swift; sourceTree = "<group>"; }; B5DE522F230BDA1300A22534 /* CoreStoreDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreStoreDefaults.swift; sourceTree = "<group>"; };
B5E1B5921CAA0C15007FD580 /* CSObjectMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSObjectMonitor.swift; sourceTree = "<group>"; }; B5E1B5921CAA0C15007FD580 /* CSObjectMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSObjectMonitor.swift; sourceTree = "<group>"; };
B5E1B5971CAA0C23007FD580 /* CSObjectObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSObjectObserver.swift; sourceTree = "<group>"; }; B5E1B5971CAA0C23007FD580 /* CSObjectObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSObjectObserver.swift; sourceTree = "<group>"; };
B5E1B59C1CAA2568007FD580 /* CSDataStack+Observing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CSDataStack+Observing.swift"; sourceTree = "<group>"; }; B5E1B59C1CAA2568007FD580 /* CSDataStack+Observing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CSDataStack+Observing.swift"; sourceTree = "<group>"; };
@@ -1141,8 +1147,8 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
B501323F23477FE800FC238B /* SwiftUI.framework in Frameworks */,
B501323D23477FD500FC238B /* UIKit.framework in Frameworks */, B501323D23477FD500FC238B /* UIKit.framework in Frameworks */,
B501323F23477FE800FC238B /* SwiftUI.framework in Frameworks */,
B56507961D3930C1000596DA /* Foundation.framework in Frameworks */, B56507961D3930C1000596DA /* Foundation.framework in Frameworks */,
B56507941D3930BC000596DA /* CoreData.framework in Frameworks */, B56507941D3930BC000596DA /* CoreData.framework in Frameworks */,
); );
@@ -1179,6 +1185,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
B5AA37FD235C3D1A00FFD4B9 /* SwiftUI.framework in Frameworks */,
B565079A1D3930D1000596DA /* Foundation.framework in Frameworks */, B565079A1D3930D1000596DA /* Foundation.framework in Frameworks */,
B56507981D3930CC000596DA /* CoreData.framework in Frameworks */, B56507981D3930CC000596DA /* CoreData.framework in Frameworks */,
); );
@@ -1229,11 +1236,9 @@
children = ( children = (
2F03A53419C5C6DA005002A5 /* Info.plist */, 2F03A53419C5C6DA005002A5 /* Info.plist */,
B5E84ED81AFF82360064E85B /* README.md */, B5E84ED81AFF82360064E85B /* README.md */,
B500810F2290CDF800F4CEA5 /* bitrise.yml */,
B5E84ED91AFF82360064E85B /* LICENSE */, B5E84ED91AFF82360064E85B /* LICENSE */,
B5D9C8F61B160ED200E64F0E /* CoreStore.podspec */, B5D9C8F61B160ED200E64F0E /* CoreStore.podspec */,
B5D2D5A91F7558CB00A4DE67 /* .cocoapods.yml */, B5D2D5A91F7558CB00A4DE67 /* .cocoapods.yml */,
B5BDC9271C2024F2008147CD /* .travis.yml */,
B524E78721CA20AC00BEB794 /* .jazzy.yaml */, B524E78721CA20AC00BEB794 /* .jazzy.yaml */,
B5AD60CD1C90141E00F2B2E8 /* Package.swift */, B5AD60CD1C90141E00F2B2E8 /* Package.swift */,
); );
@@ -1287,6 +1292,8 @@
2F291E3119C6D4D3007AF63F /* Frameworks */ = { 2F291E3119C6D4D3007AF63F /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
B5AA37FC235C3D1A00FFD4B9 /* SwiftUI.framework */,
B5AA37FA235C3D1300FFD4B9 /* UIKit.framework */,
B501323E23477FE800FC238B /* SwiftUI.framework */, B501323E23477FE800FC238B /* SwiftUI.framework */,
B501323C23477FD500FC238B /* UIKit.framework */, B501323C23477FD500FC238B /* UIKit.framework */,
B501323A23477FB600FC238B /* AppKit.framework */, B501323A23477FB600FC238B /* AppKit.framework */,
@@ -1513,7 +1520,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
2F291E2619C6D3CF007AF63F /* CoreStore.swift */, 2F291E2619C6D3CF007AF63F /* CoreStore.swift */,
B5DE522F230BDA1300A22534 /* Shared.swift */, B5DE522F230BDA1300A22534 /* CoreStoreDefaults.swift */,
B5D1E22B19FA9FBC003B2874 /* CoreStoreError.swift */, B5D1E22B19FA9FBC003B2874 /* CoreStoreError.swift */,
B549F6721E56A92800FBAB2D /* CoreDataNativeType.swift */, B549F6721E56A92800FBAB2D /* CoreDataNativeType.swift */,
B5D339F01E94AF5800C880DE /* CoreStoreStrings.swift */, B5D339F01E94AF5800C880DE /* CoreStoreStrings.swift */,
@@ -1595,8 +1602,9 @@
B50EE14123473C92009B8C47 /* CoreStoreObject+DataSources.swift */, B50EE14123473C92009B8C47 /* CoreStoreObject+DataSources.swift */,
B5D8CA752346E7590055D7D1 /* DataStack+DataSources.swift */, B5D8CA752346E7590055D7D1 /* DataStack+DataSources.swift */,
B5BF7FB1234C97910070E741 /* DiffableDataSource.swift */, B5BF7FB1234C97910070E741 /* DiffableDataSource.swift */,
B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView.swift */, B5BF7FB6234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift */,
B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView.swift */, B5635D132356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift */,
B5AA37F0235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift */,
); );
name = DataSources; name = DataSources;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -2076,8 +2084,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
B5DE5230230BDA1300A22534 /* Shared.swift in Sources */, B5DE5230230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */,
B55BB4DB23503B9700C33E34 /* EnvironmentValues+DataSources.swift in Sources */,
B5E84F221AFF84860064E85B /* ObjectMonitor.swift in Sources */, B5E84F221AFF84860064E85B /* ObjectMonitor.swift in Sources */,
B5ECDBF91CA804FD00C7F112 /* NSManagedObjectContext+ObjectiveC.swift in Sources */, B5ECDBF91CA804FD00C7F112 /* NSManagedObjectContext+ObjectiveC.swift in Sources */,
B5CA2B081F7E5ACA004B1936 /* WhereClauseType.swift in Sources */, B5CA2B081F7E5ACA004B1936 /* WhereClauseType.swift in Sources */,
@@ -2102,17 +2109,19 @@
B52FD3AA1E3B3EF10001D919 /* NSManagedObject+Logging.swift in Sources */, B52FD3AA1E3B3EF10001D919 /* NSManagedObject+Logging.swift in Sources */,
B52F74411E9B8724005F3DAC /* UnsafeDataModelSchema.swift in Sources */, B52F74411E9B8724005F3DAC /* UnsafeDataModelSchema.swift in Sources */,
B51FE5AB1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */, B51FE5AB1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */,
B55BB4DB23503B9700C33E34 /* EnvironmentValues+DataSources.swift in Sources */,
B5A9921F1EA898710091A2E3 /* UserInfo.swift in Sources */, B5A9921F1EA898710091A2E3 /* UserInfo.swift in Sources */,
B54A6A551BA15F2A007870FD /* Internals.FetchedResultsControllerDelegate.swift in Sources */, B54A6A551BA15F2A007870FD /* Internals.FetchedResultsControllerDelegate.swift in Sources */,
B5D339E21E948C3600C880DE /* Value.swift in Sources */, B5D339E21E948C3600C880DE /* Value.swift in Sources */,
B5A261211B64BFDB006EB6D3 /* MigrationType.swift in Sources */, B5A261211B64BFDB006EB6D3 /* MigrationType.swift in Sources */,
B53FBA0B1CAB5E6500F0D40A /* CSCoreStore+Migrating.swift in Sources */, B53FBA0B1CAB5E6500F0D40A /* CSCoreStore+Migrating.swift in Sources */,
B5E84F141AFF847B0064E85B /* DataStack+Querying.swift in Sources */, B5E84F141AFF847B0064E85B /* DataStack+Querying.swift in Sources */,
B5AA37F1235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift in Sources */,
B5D7A5B61CA3BF8F005C752B /* CSInto.swift in Sources */, B5D7A5B61CA3BF8F005C752B /* CSInto.swift in Sources */,
B56007141B3F6C2800A9A8F9 /* SectionBy.swift in Sources */, B56007141B3F6C2800A9A8F9 /* SectionBy.swift in Sources */,
B5DE522B230BD7CC00A22534 /* Internals.swift in Sources */, B5DE522B230BD7CC00A22534 /* Internals.swift in Sources */,
B5E84F371AFF85470064E85B /* NSManagedObjectContext+Transaction.swift in Sources */, B5E84F371AFF85470064E85B /* NSManagedObjectContext+Transaction.swift in Sources */,
B5BF7FB7234C97CE0070E741 /* DiffableDataSource.TableView.swift in Sources */, B5BF7FB7234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift in Sources */,
B5ECDC1D1CA81A2100C7F112 /* CSDataStack+Querying.swift in Sources */, B5ECDC1D1CA81A2100C7F112 /* CSDataStack+Querying.swift in Sources */,
B5C976E31C6C9F6A00B1AF90 /* UnsafeDataTransaction+Observing.swift in Sources */, B5C976E31C6C9F6A00B1AF90 /* UnsafeDataTransaction+Observing.swift in Sources */,
B53FBA121CAB63CB00F0D40A /* Progress+ObjectiveC.swift in Sources */, B53FBA121CAB63CB00F0D40A /* Progress+ObjectiveC.swift in Sources */,
@@ -2137,7 +2146,7 @@
B56923F01EB827F6007C4DC9 /* XcodeSchemaMappingProvider.swift in Sources */, B56923F01EB827F6007C4DC9 /* XcodeSchemaMappingProvider.swift in Sources */,
B5E84F121AFF847B0064E85B /* OrderBy.swift in Sources */, B5E84F121AFF847B0064E85B /* OrderBy.swift in Sources */,
B546F9581C99B17400D5AC55 /* CSCoreStore+Setup.swift in Sources */, B546F9581C99B17400D5AC55 /* CSCoreStore+Setup.swift in Sources */,
B5635D142356C39500B80E6B /* DiffableDataSource.CollectionView.swift in Sources */, B5635D142356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift in Sources */,
B5E84F361AFF85470064E85B /* NSManagedObjectContext+Setup.swift in Sources */, B5E84F361AFF85470064E85B /* NSManagedObjectContext+Setup.swift in Sources */,
B5FAD6AE1B518DCB00714891 /* CoreStore+Migration.swift in Sources */, B5FAD6AE1B518DCB00714891 /* CoreStore+Migration.swift in Sources */,
B50E175223517C6B004F033C /* Internals.DiffableDataUIDispatcher.Changeset.swift in Sources */, B50E175223517C6B004F033C /* Internals.DiffableDataUIDispatcher.Changeset.swift in Sources */,
@@ -2301,7 +2310,7 @@
files = ( files = (
82BA18B61C4BBD3F00A0916E /* DataStack+Querying.swift in Sources */, 82BA18B61C4BBD3F00A0916E /* DataStack+Querying.swift in Sources */,
B5ECDBFB1CA804FD00C7F112 /* NSManagedObjectContext+ObjectiveC.swift in Sources */, B5ECDBFB1CA804FD00C7F112 /* NSManagedObjectContext+ObjectiveC.swift in Sources */,
B5635D152356C39500B80E6B /* DiffableDataSource.CollectionView.swift in Sources */, B5635D152356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift in Sources */,
B5CA2B091F7E5ACA004B1936 /* WhereClauseType.swift in Sources */, B5CA2B091F7E5ACA004B1936 /* WhereClauseType.swift in Sources */,
B5C976E81C6E3A5D00B1AF90 /* Internals.CoreStoreFetchedResultsController.swift in Sources */, B5C976E81C6E3A5D00B1AF90 /* Internals.CoreStoreFetchedResultsController.swift in Sources */,
B56923F61EB828BF007C4DC9 /* CSDynamicSchema.swift in Sources */, B56923F61EB828BF007C4DC9 /* CSDynamicSchema.swift in Sources */,
@@ -2393,7 +2402,7 @@
82BA18C91C4BBD5900A0916E /* MigrationType.swift in Sources */, 82BA18C91C4BBD5900A0916E /* MigrationType.swift in Sources */,
B5D8CA772346EAEE0055D7D1 /* DataStack+DataSources.swift in Sources */, B5D8CA772346EAEE0055D7D1 /* DataStack+DataSources.swift in Sources */,
82BA18D01C4BBD7100A0916E /* Internals.MigrationManager.swift in Sources */, 82BA18D01C4BBD7100A0916E /* Internals.MigrationManager.swift in Sources */,
B5DE5231230BDA1300A22534 /* Shared.swift in Sources */, B5DE5231230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */,
B52F74461E9B8724005F3DAC /* XcodeDataModelSchema.swift in Sources */, B52F74461E9B8724005F3DAC /* XcodeDataModelSchema.swift in Sources */,
82BA18C61C4BBD5900A0916E /* DataStack+Migration.swift in Sources */, 82BA18C61C4BBD5900A0916E /* DataStack+Migration.swift in Sources */,
B59851491C90289D00C99590 /* NSPersistentStoreCoordinator+Setup.swift in Sources */, B59851491C90289D00C99590 /* NSPersistentStoreCoordinator+Setup.swift in Sources */,
@@ -2459,6 +2468,7 @@
B52F743E1E9B8724005F3DAC /* DynamicSchema.swift in Sources */, B52F743E1E9B8724005F3DAC /* DynamicSchema.swift in Sources */,
18166884232B9ED00097C275 /* KeyPath+KeyPaths.swift in Sources */, 18166884232B9ED00097C275 /* KeyPath+KeyPaths.swift in Sources */,
B5E8A72121C1015300EF006A /* CoreStoreObject+Observing.swift in Sources */, B5E8A72121C1015300EF006A /* CoreStoreObject+Observing.swift in Sources */,
B5AA37F2235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift in Sources */,
B50E175D2351848E004F033C /* Internals.DiffableDataUIDispatcher.DiffResult.swift in Sources */, B50E175D2351848E004F033C /* Internals.DiffableDataUIDispatcher.DiffResult.swift in Sources */,
B5474D162227C08700B21FEC /* Internals.CoreStoreFetchRequest.swift in Sources */, B5474D162227C08700B21FEC /* Internals.CoreStoreFetchRequest.swift in Sources */,
B501322B2346A9AE00FC238B /* ListPublisher.swift in Sources */, B501322B2346A9AE00FC238B /* ListPublisher.swift in Sources */,
@@ -2476,7 +2486,7 @@
B5D339E81E9493A500C880DE /* Entity.swift in Sources */, B5D339E81E9493A500C880DE /* Entity.swift in Sources */,
B5BF7FC7234D7E460070E741 /* ObjectSnapshot.swift in Sources */, B5BF7FC7234D7E460070E741 /* ObjectSnapshot.swift in Sources */,
82BA18CC1C4BBD6400A0916E /* Progress+Convenience.swift in Sources */, 82BA18CC1C4BBD6400A0916E /* Progress+Convenience.swift in Sources */,
B5BF7FB8234C97CE0070E741 /* DiffableDataSource.TableView.swift in Sources */, B5BF7FB8234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift in Sources */,
82BA18C01C4BBD5300A0916E /* DataStack+Observing.swift in Sources */, 82BA18C01C4BBD5300A0916E /* DataStack+Observing.swift in Sources */,
82BA18A61C4BBD2900A0916E /* DefaultLogger.swift in Sources */, 82BA18A61C4BBD2900A0916E /* DefaultLogger.swift in Sources */,
); );
@@ -2523,7 +2533,7 @@
files = ( files = (
B5220E1E1D13080D009BC71E /* CSListMonitor.swift in Sources */, B5220E1E1D13080D009BC71E /* CSListMonitor.swift in Sources */,
B5DBE2D01C9914A900B5CEFA /* CSCoreStore.swift in Sources */, B5DBE2D01C9914A900B5CEFA /* CSCoreStore.swift in Sources */,
B5635D172356C39500B80E6B /* DiffableDataSource.CollectionView.swift in Sources */, B5635D172356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift in Sources */,
B5CA2B0B1F7E5ACA004B1936 /* WhereClauseType.swift in Sources */, B5CA2B0B1F7E5ACA004B1936 /* WhereClauseType.swift in Sources */,
B56923F81EB828BF007C4DC9 /* CSDynamicSchema.swift in Sources */, B56923F81EB828BF007C4DC9 /* CSDynamicSchema.swift in Sources */,
B52DD1BE1BE1F94300949AFE /* Progress+Convenience.swift in Sources */, B52DD1BE1BE1F94300949AFE /* Progress+Convenience.swift in Sources */,
@@ -2615,7 +2625,7 @@
B5ECDC091CA8138100C7F112 /* CSOrderBy.swift in Sources */, B5ECDC091CA8138100C7F112 /* CSOrderBy.swift in Sources */,
B5D8CA792346EAEF0055D7D1 /* DataStack+DataSources.swift in Sources */, B5D8CA792346EAEF0055D7D1 /* DataStack+DataSources.swift in Sources */,
B56923C71EB823B4007C4DC9 /* NSEntityDescription+Migration.swift in Sources */, B56923C71EB823B4007C4DC9 /* NSEntityDescription+Migration.swift in Sources */,
B5DE5233230BDA1300A22534 /* Shared.swift in Sources */, B5DE5233230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */,
B52DD1A51BE1F92F00949AFE /* ImportableUniqueObject.swift in Sources */, B52DD1A51BE1F92F00949AFE /* ImportableUniqueObject.swift in Sources */,
B5E222271CA4E12600BA2E95 /* CSSynchronousDataTransaction.swift in Sources */, B5E222271CA4E12600BA2E95 /* CSSynchronousDataTransaction.swift in Sources */,
B52F74481E9B8724005F3DAC /* XcodeDataModelSchema.swift in Sources */, B52F74481E9B8724005F3DAC /* XcodeDataModelSchema.swift in Sources */,
@@ -2681,6 +2691,7 @@
B52F74401E9B8724005F3DAC /* DynamicSchema.swift in Sources */, B52F74401E9B8724005F3DAC /* DynamicSchema.swift in Sources */,
18166886232B9ED20097C275 /* KeyPath+KeyPaths.swift in Sources */, 18166886232B9ED20097C275 /* KeyPath+KeyPaths.swift in Sources */,
B5E8A72321C1015300EF006A /* CoreStoreObject+Observing.swift in Sources */, B5E8A72321C1015300EF006A /* CoreStoreObject+Observing.swift in Sources */,
B5AA37F4235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift in Sources */,
B50E175F2351848E004F033C /* Internals.DiffableDataUIDispatcher.DiffResult.swift in Sources */, B50E175F2351848E004F033C /* Internals.DiffableDataUIDispatcher.DiffResult.swift in Sources */,
B5474D182227C08700B21FEC /* Internals.CoreStoreFetchRequest.swift in Sources */, B5474D182227C08700B21FEC /* Internals.CoreStoreFetchRequest.swift in Sources */,
B501322E2346A9B100FC238B /* ListPublisher.swift in Sources */, B501322E2346A9B100FC238B /* ListPublisher.swift in Sources */,
@@ -2698,7 +2709,7 @@
B5D339EA1E9493A500C880DE /* Entity.swift in Sources */, B5D339EA1E9493A500C880DE /* Entity.swift in Sources */,
B5BF7FC9234D7E460070E741 /* ObjectSnapshot.swift in Sources */, B5BF7FC9234D7E460070E741 /* ObjectSnapshot.swift in Sources */,
B52DD1AA1BE1F93500949AFE /* TypeErasedClauses.swift in Sources */, B52DD1AA1BE1F93500949AFE /* TypeErasedClauses.swift in Sources */,
B5BF7FBA234C97CE0070E741 /* DiffableDataSource.TableView.swift in Sources */, B5BF7FBA234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift in Sources */,
B53FBA021CAB2D2F00F0D40A /* CSMigrationResult.swift in Sources */, B53FBA021CAB2D2F00F0D40A /* CSMigrationResult.swift in Sources */,
B51FE5AF1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */, B51FE5AF1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */,
); );
@@ -2745,7 +2756,7 @@
files = ( files = (
B56321A91BD65219006C9394 /* Progress+Convenience.swift in Sources */, B56321A91BD65219006C9394 /* Progress+Convenience.swift in Sources */,
B5ECDBFC1CA804FD00C7F112 /* NSManagedObjectContext+ObjectiveC.swift in Sources */, B5ECDBFC1CA804FD00C7F112 /* NSManagedObjectContext+ObjectiveC.swift in Sources */,
B5635D162356C39500B80E6B /* DiffableDataSource.CollectionView.swift in Sources */, B5635D162356C39500B80E6B /* DiffableDataSource.CollectionView-UIKit.swift in Sources */,
B5CA2B0A1F7E5ACA004B1936 /* WhereClauseType.swift in Sources */, B5CA2B0A1F7E5ACA004B1936 /* WhereClauseType.swift in Sources */,
B5C976E91C6E3A5E00B1AF90 /* Internals.CoreStoreFetchedResultsController.swift in Sources */, B5C976E91C6E3A5E00B1AF90 /* Internals.CoreStoreFetchedResultsController.swift in Sources */,
B56923F71EB828BF007C4DC9 /* CSDynamicSchema.swift in Sources */, B56923F71EB828BF007C4DC9 /* CSDynamicSchema.swift in Sources */,
@@ -2838,7 +2849,7 @@
B5D8CA782346EAEF0055D7D1 /* DataStack+DataSources.swift in Sources */, B5D8CA782346EAEF0055D7D1 /* DataStack+DataSources.swift in Sources */,
B56923C61EB823B4007C4DC9 /* NSEntityDescription+Migration.swift in Sources */, B56923C61EB823B4007C4DC9 /* NSEntityDescription+Migration.swift in Sources */,
B56321A71BD65216006C9394 /* MigrationResult.swift in Sources */, B56321A71BD65216006C9394 /* MigrationResult.swift in Sources */,
B5DE5232230BDA1300A22534 /* Shared.swift in Sources */, B5DE5232230BDA1300A22534 /* CoreStoreDefaults.swift in Sources */,
B598514A1C90289E00C99590 /* NSPersistentStoreCoordinator+Setup.swift in Sources */, B598514A1C90289E00C99590 /* NSPersistentStoreCoordinator+Setup.swift in Sources */,
B52F74471E9B8724005F3DAC /* XcodeDataModelSchema.swift in Sources */, B52F74471E9B8724005F3DAC /* XcodeDataModelSchema.swift in Sources */,
B5FEC1901C9166E700532541 /* NSPersistentStore+Setup.swift in Sources */, B5FEC1901C9166E700532541 /* NSPersistentStore+Setup.swift in Sources */,
@@ -2903,6 +2914,7 @@
B52F743F1E9B8724005F3DAC /* DynamicSchema.swift in Sources */, B52F743F1E9B8724005F3DAC /* DynamicSchema.swift in Sources */,
18166885232B9ED10097C275 /* KeyPath+KeyPaths.swift in Sources */, 18166885232B9ED10097C275 /* KeyPath+KeyPaths.swift in Sources */,
B5E8A72221C1015300EF006A /* CoreStoreObject+Observing.swift in Sources */, B5E8A72221C1015300EF006A /* CoreStoreObject+Observing.swift in Sources */,
B5AA37F3235C28EE00FFD4B9 /* diffableDataSource.CollectionView-AppKit.swift in Sources */,
B50E175E2351848E004F033C /* Internals.DiffableDataUIDispatcher.DiffResult.swift in Sources */, B50E175E2351848E004F033C /* Internals.DiffableDataUIDispatcher.DiffResult.swift in Sources */,
B5474D172227C08700B21FEC /* Internals.CoreStoreFetchRequest.swift in Sources */, B5474D172227C08700B21FEC /* Internals.CoreStoreFetchRequest.swift in Sources */,
B501322D2346A9B000FC238B /* ListPublisher.swift in Sources */, B501322D2346A9B000FC238B /* ListPublisher.swift in Sources */,
@@ -2920,7 +2932,7 @@
B5D339E91E9493A500C880DE /* Entity.swift in Sources */, B5D339E91E9493A500C880DE /* Entity.swift in Sources */,
B5BF7FC8234D7E460070E741 /* ObjectSnapshot.swift in Sources */, B5BF7FC8234D7E460070E741 /* ObjectSnapshot.swift in Sources */,
B56321A41BD65216006C9394 /* CoreStore+Migration.swift in Sources */, B56321A41BD65216006C9394 /* CoreStore+Migration.swift in Sources */,
B5BF7FB9234C97CE0070E741 /* DiffableDataSource.TableView.swift in Sources */, B5BF7FB9234C97CE0070E741 /* DiffableDataSource.TableView-UIKit.swift in Sources */,
B56321A01BD65216006C9394 /* ObjectObserver.swift in Sources */, B56321A01BD65216006C9394 /* ObjectObserver.swift in Sources */,
B56321951BD65216006C9394 /* TypeErasedClauses.swift in Sources */, B56321951BD65216006C9394 /* TypeErasedClauses.swift in Sources */,
); );

View File

@@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"> shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B52DD1731BE1F8CC00949AFE"
BuildableName = "CoreStore.framework"
BlueprintName = "CoreStore OSX"
ReferencedContainer = "container:CoreStore.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables> <Testables>
<TestableReference <TestableReference
skipped = "NO"> skipped = "NO">
@@ -39,17 +48,6 @@
</BuildableReference> </BuildableReference>
</TestableReference> </TestableReference>
</Testables> </Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B52DD1731BE1F8CC00949AFE"
BuildableName = "CoreStore.framework"
BlueprintName = "CoreStore OSX"
ReferencedContainer = "container:CoreStore.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Debug"
@@ -70,8 +68,6 @@
ReferencedContainer = "container:CoreStore.xcodeproj"> ReferencedContainer = "container:CoreStore.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"

View File

@@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"> shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82BA18881C4BBCBA00A0916E"
BuildableName = "CoreStore.framework"
BlueprintName = "CoreStore tvOS"
ReferencedContainer = "container:CoreStore.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables> <Testables>
<TestableReference <TestableReference
skipped = "NO"> skipped = "NO">
@@ -39,17 +48,6 @@
</BuildableReference> </BuildableReference>
</TestableReference> </TestableReference>
</Testables> </Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82BA18881C4BBCBA00A0916E"
BuildableName = "CoreStore.framework"
BlueprintName = "CoreStore tvOS"
ReferencedContainer = "container:CoreStore.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Debug"
@@ -70,8 +68,6 @@
ReferencedContainer = "container:CoreStore.xcodeproj"> ReferencedContainer = "container:CoreStore.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"

View File

@@ -29,8 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES"> shouldUseLaunchSchemeArgsEnv = "YES">
<Testables> <Testables>
</Testables> </Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Debug"
@@ -51,8 +49,6 @@
ReferencedContainer = "container:CoreStore.xcodeproj"> ReferencedContainer = "container:CoreStore.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"

View File

@@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"> shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion> <MacroExpansion>
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
@@ -38,8 +36,8 @@
ReferencedContainer = "container:CoreStoreDemo.xcodeproj"> ReferencedContainer = "container:CoreStoreDemo.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions> <Testables>
</AdditionalOptions> </Testables>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Debug"
@@ -61,8 +59,6 @@
ReferencedContainer = "container:CoreStoreDemo.xcodeproj"> ReferencedContainer = "container:CoreStoreDemo.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"

View File

@@ -31,7 +31,7 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger {
super.viewDidAppear(animated) super.viewDidAppear(animated)
Shared.logger = self CoreStoreDefaults.logger = self
let alert = UIAlertController( let alert = UIAlertController(
title: "Logger Demo", title: "Logger Demo",
@@ -46,7 +46,7 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger {
super.viewDidDisappear(animated) super.viewDidDisappear(animated)
Shared.logger = DefaultLogger() CoreStoreDefaults.logger = DefaultLogger()
} }

View File

@@ -13,13 +13,19 @@ import CoreStore
import SwiftUI import SwiftUI
#endif #endif
#if canImport(Combine)
import Combine
#endif
import Compression import Compression
final class SwiftUIContainerViewController: UIViewController { final class SwiftUIContainerViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
#if canImport(SwiftUI) #if canImport(SwiftUI) && canImport(Combine)
if #available(iOS 13, *) { if #available(iOS 13, *) {

View File

@@ -6,11 +6,13 @@
// Copyright © 2019 John Rommel Estropia. All rights reserved. // Copyright © 2019 John Rommel Estropia. All rights reserved.
// //
#if canImport(SwiftUI) #if canImport(SwiftUI) && canImport(Combine)
import SwiftUI import SwiftUI
import Combine
import CoreStore import CoreStore
@available(iOS 13.0.0, *) @available(iOS 13.0.0, *)
struct SwiftUIView: View { struct SwiftUIView: View {

View File

@@ -67,11 +67,11 @@ class BaseTestCase: XCTestCase {
@nonobjc @nonobjc
func expectLogger<T>(_ expectations: [TestLogger.Expectation], closure: () throws -> T) rethrows -> T { func expectLogger<T>(_ expectations: [TestLogger.Expectation], closure: () throws -> T) rethrows -> T {
Shared.logger = TestLogger(self.prepareLoggerExpectations(expectations)) CoreStoreDefaults.logger = TestLogger(self.prepareLoggerExpectations(expectations))
defer { defer {
self.checkExpectationsImmediately() self.checkExpectationsImmediately()
Shared.logger = TestLogger([:]) CoreStoreDefaults.logger = TestLogger([:])
} }
return try closure() return try closure()
} }
@@ -79,17 +79,17 @@ class BaseTestCase: XCTestCase {
@nonobjc @nonobjc
func expectLogger(_ expectations: [TestLogger.Expectation: XCTestExpectation]) { func expectLogger(_ expectations: [TestLogger.Expectation: XCTestExpectation]) {
Shared.logger = TestLogger(expectations) CoreStoreDefaults.logger = TestLogger(expectations)
} }
@nonobjc @nonobjc
func expectError<T>(code: CoreStoreErrorCode, closure: () throws -> T) { func expectError<T>(code: CoreStoreErrorCode, closure: () throws -> T) {
Shared.logger = TestLogger(self.prepareLoggerExpectations([.logError])) CoreStoreDefaults.logger = TestLogger(self.prepareLoggerExpectations([.logError]))
defer { defer {
self.checkExpectationsImmediately() self.checkExpectationsImmediately()
Shared.logger = TestLogger([:]) CoreStoreDefaults.logger = TestLogger([:])
} }
do { do {
@@ -138,12 +138,12 @@ class BaseTestCase: XCTestCase {
super.setUp() super.setUp()
self.deleteStores() self.deleteStores()
Shared.logger = TestLogger([:]) CoreStoreDefaults.logger = TestLogger([:])
} }
override func tearDown() { override func tearDown() {
Shared.logger = DefaultLogger() CoreStoreDefaults.logger = DefaultLogger()
self.deleteStores() self.deleteStores()
super.tearDown() super.tearDown()
} }

204
README.md
View File

@@ -5,7 +5,7 @@
Unleashing the real power of Core Data with the elegance and safety of Swift Unleashing the real power of Core Data with the elegance and safety of Swift
<br /> <br />
<br /> <br />
<a href="https://app.bitrise.io/app/e736852157296019#/builds"><img alt="Build Status" src="https://img.shields.io/bitrise/e736852157296019/master.svg?label=build&token=vhgAmaiF3tWZoQyFLkKM7g" /></a> <a href="https://app.bitrise.io/app/e736852157296019#/builds"><img alt="Build Status" src="https://img.shields.io/bitrise/e736852157296019/master.svg?label=build&token=vhgAmaiF3tWZoQyFLkKM7g&logo=bitrise" /></a>
<a href="https://github.com/JohnEstropia/CoreStore/commits"><img alt="Last Commit" src="https://img.shields.io/github/last-commit/johnestropia/corestore.svg?style=flat" /></a> <a href="https://github.com/JohnEstropia/CoreStore/commits"><img alt="Last Commit" src="https://img.shields.io/github/last-commit/johnestropia/corestore.svg?style=flat" /></a>
<a href="http://cocoadocs.org/docsets/CoreStore"><img alt="Platform" src="https://img.shields.io/cocoapods/p/CoreStore.svg?style=flat" /></a> <a href="http://cocoadocs.org/docsets/CoreStore"><img alt="Platform" src="https://img.shields.io/cocoapods/p/CoreStore.svg?style=flat" /></a>
<a href="https://raw.githubusercontent.com/JohnEstropia/CoreStore/master/LICENSE"><img alt="License" src="https://img.shields.io/cocoapods/l/CoreStore.svg?style=flat" /></a> <a href="https://raw.githubusercontent.com/JohnEstropia/CoreStore/master/LICENSE"><img alt="License" src="https://img.shields.io/cocoapods/l/CoreStore.svg?style=flat" /></a>
@@ -14,15 +14,15 @@ Unleashing the real power of Core Data with the elegance and safety of Swift
<a href="https://github.com/Carthage/Carthage"><img alt="Carthage compatible" src="https://img.shields.io/badge/Carthage-compatible-16a085.svg?style=flat" /></a> <a href="https://github.com/Carthage/Carthage"><img alt="Carthage compatible" src="https://img.shields.io/badge/Carthage-compatible-16a085.svg?style=flat" /></a>
<a href="https://swift.org/source-compatibility/#current-list-of-projects"><img alt="Swift Package Manager compatible" src="https://img.shields.io/badge/Swift_Package_Manager-compatible-orange.svg?style=flat" /></a> <a href="https://swift.org/source-compatibility/#current-list-of-projects"><img alt="Swift Package Manager compatible" src="https://img.shields.io/badge/Swift_Package_Manager-compatible-orange.svg?style=flat" /></a>
<br /><br />Contact<br /> <br /><br />Contact<br />
<a href="http://swift-corestore-slack.herokuapp.com/"><img alt="Join us on Slack!" src="http://swift-corestore-slack.herokuapp.com/badge.svg" /></a> <a href="http://swift-corestore-slack.herokuapp.com/"><img alt="Join us on Slack!" src="http://swift-corestore-slack.herokuapp.com/badge.svg?logo=slack" /></a>
<a href="https://twitter.com/JohnEstropia"><img alt="Reach me on Twitter!" src="https://img.shields.io/badge/twitter-%40JohnEstropia-3498db.svg" /></a> <a href="https://twitter.com/JohnEstropia"><img alt="Reach me on Twitter!" src="https://img.shields.io/badge/twitter-%40JohnEstropia-3498db.svg?logo=twitter" /></a>
<br /> <br />
</p> </p>
* **Swift 5.0:** iOS 10+ / macOS 10.12+ / watchOS 3.0+ / tvOS 10.0+ * **Swift 5.1:** iOS 10+ / macOS 10.12+ / watchOS 3.0+ / tvOS 10.0+
* Previously supported Swift versions: [Swift 3.2](https://github.com/JohnEstropia/CoreStore/tree/4.2.3), [Swift 4.2](https://github.com/JohnEstropia/CoreStore/tree/6.2.1) * Previously supported Swift versions: [Swift 3.2](https://github.com/JohnEstropia/CoreStore/tree/4.2.3), [Swift 4.2](https://github.com/JohnEstropia/CoreStore/tree/6.2.1), [Swift 5.0](https://github.com/JohnEstropia/CoreStore/tree/6.3.2)
Upgrading from CoreStore 5.x (min iOS 9) to 6.x (min iOS 10)? Check out the [new features](#features) and make sure to read the [Change logs](https://github.com/JohnEstropia/CoreStore/releases). Upgrading from CoreStore 6.x (swift 5.0) to 7.x (Swift 5.1)? Check out the [🆕 features](#features) and make sure to read the [Change logs](https://github.com/JohnEstropia/CoreStore/releases).
CoreStore is now part of the [Swift Source Compatibility projects](https://swift.org/source-compatibility/#current-list-of-projects). CoreStore is now part of the [Swift Source Compatibility projects](https://swift.org/source-compatibility/#current-list-of-projects).
@@ -36,14 +36,14 @@ CoreStore was (and is) heavily shaped by real-world needs of developing data-dep
- **💎Tight design around Swifts code elegance and type safety.** CoreStore fully utilizes Swift's community-driven language features. - **💎Tight design around Swifts code elegance and type safety.** CoreStore fully utilizes Swift's community-driven language features.
- **🚦Safer concurrency architecture.** CoreStore makes it hard to fall into common concurrency mistakes. The main `NSManagedObjectContext` is strictly read-only, while all updates are done through serial *transactions*. *(See [Saving and processing transactions](#saving-and-processing-transactions))* - **🚦Safer concurrency architecture.** CoreStore makes it hard to fall into common concurrency mistakes. The main `NSManagedObjectContext` is strictly read-only, while all updates are done through serial *transactions*. *(See [Saving and processing transactions](#saving-and-processing-transactions))*
- **🔍Clean fetching and querying API.** Fetching objects is easy, but querying for raw aggregates (`min`, `max`, etc.) and raw property values is now just as convenient. *(See [Fetching and querying](#fetching-and-querying))* - **🔍Clean fetching and querying API.** Fetching objects is easy, but querying for raw aggregates (`min`, `max`, etc.) and raw property values is now just as convenient. *(See [Fetching and querying](#fetching-and-querying))*
- **🔭Type-safe, easy to configure observers.** You don't have to deal with the burden of setting up `NSFetchedResultsController`s and KVO. As an added bonus, `ListMonitor`s and `ObjectMonitor`s can have multiple observers. This means you can have multiple view controllers efficiently share a single resource! *(See [Observing changes and notifications](#observing-changes-and-notifications))* - **🔭Type-safe, easy to configure observers.** You don't have to deal with the burden of setting up `NSFetchedResultsController`s and KVO. As an added bonus, list and object observable types all support multiple observers. This means you can have multiple view controllers efficiently share a single resource! *(See [Observing changes and notifications](#observing-changes-and-notifications))*
- **📥Efficient importing utilities.** Map your entities once with their corresponding import source (JSON for example), and importing from *transactions* becomes elegant. Uniquing is also done with an efficient find-and-replace algorithm. *(See [Importing data](#importing-data))* - **📥Efficient importing utilities.** Map your entities once with their corresponding import source (JSON for example), and importing from *transactions* becomes elegant. Uniquing is also done with an efficient find-and-replace algorithm. *(See [Importing data](#importing-data))*
- **🗑Say goodbye to *.xcdatamodeld* files!** The new `CoreStoreObject` is *the* replacement to `NSManagedObject`. `CoreStoreObject` subclasses can declare type-safe properties all in Swift code, no need to maintain separate resource files for the models. As bonus, these special properties support custom types, and can be used to create type-safe keypaths and queries. *(See [Type-safe `CoreStoreObject`s](#type-safe-corestoreobjects))* - **🗑Say goodbye to *.xcdatamodeld* files!** While CoreStore supports `NSManagedObject`s, it offers `CoreStoreObject` whose subclasses can declare type-safe properties all in Swift code without the need to maintain separate resource files for the models. As bonus, these special properties support custom types, and can be used to create type-safe keypaths and queries. *(See [Type-safe `CoreStoreObject`s](#type-safe-corestoreobjects))*
- **🔗Progressive migrations.** No need to think how to migrate from all previous model versions to your latest model. Just tell the `DataStack` the sequence of version strings (`MigrationChain`s) and CoreStore will automatically use progressive migrations when needed. *(See [Migrations](#migrations))* - **🔗Progressive migrations.** No need to think how to migrate from all previous model versions to your latest model. Just tell the `DataStack` the sequence of version strings (`MigrationChain`s) and CoreStore will automatically use progressive migrations when needed. *(See [Migrations](#migrations))*
- **Easier custom migrations.** Say goodbye to *.xcmappingmodel* files; CoreStore can now infer entity mappings when possible, while still allowing an easy way to write custom mappings. *(See [Migrations](#migrations))* - **Easier custom migrations.** Say goodbye to *.xcmappingmodel* files; CoreStore can now infer entity mappings when possible, while still allowing an easy way to write custom mappings. *(See [Migrations](#migrations))*
- **📝Plug-in your own logging framework.** Although a default logger is built-in, all logging, asserting, and error reporting can be funneled to `CoreStoreLogger` protocol implementations. *(See [Logging and error reporting](#logging-and-error-reporting))* - **📝Plug-in your own logging framework.** Although a default logger is built-in, all logging, asserting, and error reporting can be funneled to `CoreStoreLogger` protocol implementations. *(See [Logging and error reporting](#logging-and-error-reporting))*
- **⛓Heavy support for multiple persistent stores per data stack.** CoreStore lets you manage separate stores in a single `DataStack`, just the way *.xcdatamodeld* configurations are designed to. CoreStore will also manage one stack by default, but you can create and manage as many as you need. *(See [Setting up](#setting-up))* - **⛓Heavy support for multiple persistent stores per data stack.** CoreStore lets you manage separate stores in a single `DataStack`, just the way *.xcdatamodeld* configurations are designed to. CoreStore will also manage one stack by default, but you can create and manage as many as you need. *(See [Setting up](#setting-up))*
- **🎯Free to name entities and their class names independently.** CoreStore gets around a restriction with other Core Data wrappers where the entity name should be the same as the `NSManagedObject` subclass name. CoreStore loads entity-to-class mappings from the managed object model file, so you can assign different names for the entities and their class names. - **🎯Free to name entities and their class names independently.** CoreStore gets around a restriction with other Core Data wrappers where the entity name should be the same as the `NSManagedObject` subclass name. CoreStore loads entity-to-class mappings from the managed object model file, so you can assign independent names for the entities and their class names.
- **📙Full Documentation.** No magic here; all public classes, functions, properties, etc. have detailed *Apple Docs*. This *README* also introduces a lot of concepts and explains a lot of CoreStore's behavior. - **📙Full Documentation.** No magic here; all public classes, functions, properties, etc. have detailed *Apple Docs*. This *README* also introduces a lot of concepts and explains a lot of CoreStore's behavior.
- **Informative (and pretty) logs.** All CoreStore and Core Data-related types now have very informative and pretty print outputs! *(See [Logging and error reporting](#logging-and-error-reporting))* - **Informative (and pretty) logs.** All CoreStore and Core Data-related types now have very informative and pretty print outputs! *(See [Logging and error reporting](#logging-and-error-reporting))*
- **🎗Objective-C support!** Is your project transitioning from Objective-C to Swift but still can't quite fully convert some huge classes to Swift yet? CoreStore adjusts to the ever-increasing Swift adoption. While still written in pure Swift, all CoreStore types have their corresponding Objective-C-visible "bridging classes". *(See [Objective-C support](#objective-c-support))* - **🎗Objective-C support!** Is your project transitioning from Objective-C to Swift but still can't quite fully convert some huge classes to Swift yet? CoreStore adjusts to the ever-increasing Swift adoption. While still written in pure Swift, all CoreStore types have their corresponding Objective-C-visible "bridging classes". *(See [Objective-C support](#objective-c-support))*
@@ -105,7 +105,7 @@ CoreStore was (and is) heavily shaped by real-world needs of developing data-dep
Setting-up with progressive migration support: Setting-up with progressive migration support:
```swift ```swift
CoreStore.defaultStack = DataStack( dataStack = DataStack(
xcodeModelName: "MyStore", xcodeModelName: "MyStore",
migrationChain: ["MyStore", "MyStoreV2", "MyStoreV3"] migrationChain: ["MyStore", "MyStoreV2", "MyStoreV3"]
) )
@@ -113,7 +113,7 @@ CoreStore.defaultStack = DataStack(
Adding a store: Adding a store:
```swift ```swift
CoreStore.addStorage( dataStack.addStorage(
SQLiteStore(fileName: "MyStore.sqlite"), SQLiteStore(fileName: "MyStore.sqlite"),
completion: { (result) -> Void in completion: { (result) -> Void in
// ... // ...
@@ -123,7 +123,7 @@ CoreStore.addStorage(
Starting transactions: Starting transactions:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let person = transaction.create(Into<MyPersonEntity>()) let person = transaction.create(Into<MyPersonEntity>())
person.name = "John Smith" person.name = "John Smith"
@@ -140,12 +140,12 @@ CoreStore.perform(
Fetching objects (simple): Fetching objects (simple):
```swift ```swift
let people = try CoreStore.fetchAll(From<MyPersonEntity>()) let people = try dataStack.fetchAll(From<MyPersonEntity>())
``` ```
Fetching objects (complex): Fetching objects (complex):
```swift ```swift
let people = try CoreStore.fetchAll( let people = try dataStack.fetchAll(
From<MyPersonEntity>() From<MyPersonEntity>()
.where(\.age > 30), .where(\.age > 30),
.orderBy(.ascending(\.name), .descending(.\age)), .orderBy(.ascending(\.name), .descending(.\age)),
@@ -155,7 +155,7 @@ let people = try CoreStore.fetchAll(
Querying values: Querying values:
```swift ```swift
let maxAge = try CoreStore.queryValue( let maxAge = try dataStack.queryValue(
From<MyPersonEntity>() From<MyPersonEntity>()
.select(Int.self, .maximum(\.age)) .select(Int.self, .maximum(\.age))
) )
@@ -193,10 +193,10 @@ This allows for a butter-smooth main thread, while still taking advantage of saf
## Setting up ## Setting up
The simplest way to initialize CoreStore is to add a default store to the default stack: The simplest way to initialize CoreStore is to add a default store to the default stack:
```swift ```swift
try CoreStore.addStorageAndWait() try CoreStoreDefaults.dataStack.addStorageAndWait()
``` ```
This one-liner does the following: This one-liner does the following:
- Triggers the lazy-initialization of `CoreStore.defaultStack` with a default `DataStack` - Triggers the lazy-initialization of `CoreStoreDefaults.dataStack` with a default `DataStack`
- Sets up the stack's `NSPersistentStoreCoordinator`, the root saving `NSManagedObjectContext`, and the read-only main `NSManagedObjectContext` - Sets up the stack's `NSPersistentStoreCoordinator`, the root saving `NSManagedObjectContext`, and the read-only main `NSManagedObjectContext`
- Adds an `SQLiteStore` in the *"Application Support/<bundle id>"* directory (or the *"Caches/<bundle id>"* directory on tvOS) with the file name *"[App bundle name].sqlite"* - Adds an `SQLiteStore` in the *"Application Support/<bundle id>"* directory (or the *"Caches/<bundle id>"* directory on tvOS) with the file name *"[App bundle name].sqlite"*
- Creates and returns the `NSPersistentStore` instance on success, or an `NSError` on failure - Creates and returns the `NSPersistentStore` instance on success, or an `NSError` on failure
@@ -223,13 +223,13 @@ let migrationProgress = dataStack.addStorage(
} }
) )
CoreStore.defaultStack = dataStack // pass the dataStack to CoreStore for easier access later on CoreStoreDefaults.dataStack = dataStack // pass the dataStack to CoreStore for easier access later on
``` ```
> 💡If you have never heard of "Configurations", you'll find them in your *.xcdatamodeld* file > 💡If you have never heard of "Configurations", you'll find them in your *.xcdatamodeld* file
> <img src="https://cloud.githubusercontent.com/assets/3029684/8333192/e52cfaac-1acc-11e5-9902-08724f9f1324.png" alt="xcode configurations screenshot" height=212 /> > <img src="https://cloud.githubusercontent.com/assets/3029684/8333192/e52cfaac-1acc-11e5-9902-08724f9f1324.png" alt="xcode configurations screenshot" height=212 />
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 ```swift
class MyViewController: UIViewController { class MyViewController: UIViewController {
let dataStack = DataStack(xcodeModelName: "MyModel") // keep reference to the stack 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<MyEntity>())
print(objects)
}
}
```
> 💡By default, CoreStore will initialize `NSManagedObject`s from *.xcdatamodeld* files, but you can create models completely from source code using `CoreStoreObject`s and `CoreStoreSchema`. To use this feature, refer to [Type-safe `CoreStoreObject`s](#type-safe-corestoreobjects). > 💡By default, CoreStore will initialize `NSManagedObject`s from *.xcdatamodeld* files, but you can create models completely from source code using `CoreStoreObject`s and `CoreStoreSchema`. To use this feature, refer to [Type-safe `CoreStoreObject`s](#type-safe-corestoreobjects).
@@ -273,7 +255,7 @@ Notice that in our previous examples, `addStorageAndWait(_:)` and `addStorage(_:
### In-memory store ### In-memory store
The most basic `StorageInterface` concrete type is the `InMemoryStore`, which just stores objects in memory. Since `InMemoryStore`s always start with a fresh empty data, they do not need any migration information. The most basic `StorageInterface` concrete type is the `InMemoryStore`, which just stores objects in memory. Since `InMemoryStore`s always start with a fresh empty data, they do not need any migration information.
```swift ```swift
try CoreStore.addStorageAndWait( try dataStack.addStorageAndWait(
InMemoryStore( InMemoryStore(
configuration: "Config2" // optional. Use entities from the "Config2" configuration in the .xcdatamodeld file configuration: "Config2" // optional. Use entities from the "Config2" configuration in the .xcdatamodeld file
) )
@@ -283,7 +265,7 @@ try CoreStore.addStorageAndWait(
### Local Store ### Local Store
The most common `StorageInterface` you will probably use is the `SQLiteStore`, which saves data in a local SQLite file. The most common `StorageInterface` you will probably use is the `SQLiteStore`, which saves data in a local SQLite file.
```swift ```swift
let migrationProgress = CoreStore.addStorage( let migrationProgress = dataStack.addStorage(
SQLiteStore( SQLiteStore(
fileName: "MyStore.sqlite", fileName: "MyStore.sqlite",
configuration: "Config2", // optional. Use entities from the "Config2" configuration in the .xcdatamodeld file configuration: "Config2", // optional. Use entities from the "Config2" configuration in the .xcdatamodeld file
@@ -297,7 +279,7 @@ Refer to the *SQLiteStore.swift* source documentation for detailed explanations
CoreStore can decide the default values for these properties, so `SQLiteStore`s can be initialized with no arguments: CoreStore can decide the default values for these properties, so `SQLiteStore`s can be initialized with no arguments:
```swift ```swift
try CoreStore.addStorageAndWait(SQLiteStore()) try dataStack.addStorageAndWait(SQLiteStore())
``` ```
The file-related properties above are actually requirements of another protocol that `SQLiteStore` implements, the `LocalStorage` protocol: The file-related properties above are actually requirements of another protocol that `SQLiteStore` implements, the `LocalStorage` protocol:
@@ -318,7 +300,7 @@ If you have custom `NSIncrementalStore` or `NSAtomicStore` subclasses, you can i
### Declaring model versions ### Declaring model versions
Until CoreStore 4.0, model versions were always assumed to be declared in *.xcdatamodeld* files. The `DataStack` loads these for us by accepting the *.xcdatamodeld* file name and the `Bundle` where the files can be found: Until CoreStore 4.0, model versions were always assumed to be declared in *.xcdatamodeld* files. The `DataStack` loads these for us by accepting the *.xcdatamodeld* file name and the `Bundle` where the files can be found:
```swift ```swift
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
xcodeModelName: "MyModel", xcodeModelName: "MyModel",
bundle: Bundle.main, bundle: Bundle.main,
migrationChain: ["MyAppModel", "MyAppModelV2", "MyAppModelV3", "MyAppModelV4"] migrationChain: ["MyAppModel", "MyAppModelV2", "MyAppModelV3", "MyAppModelV4"]
@@ -334,7 +316,7 @@ All the `DynamicSchema` for all model versions are then collected within a singl
**Multiple model versions grouped in a *.xcdatamodeld* file (Core Data standard method)** **Multiple model versions grouped in a *.xcdatamodeld* file (Core Data standard method)**
```swift ```swift
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
xcodeModelName: "MyModel", xcodeModelName: "MyModel",
bundle: Bundle.main, bundle: Bundle.main,
migrationChain: ["MyAppModel", "MyAppModelV2", "MyAppModelV3", "MyAppModelV4"] migrationChain: ["MyAppModel", "MyAppModelV2", "MyAppModelV3", "MyAppModelV4"]
@@ -354,7 +336,7 @@ class Person: CoreStoreObject {
// ... // ...
} }
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
CoreStoreSchema( CoreStoreSchema(
modelVersion: "V1", modelVersion: "V1",
entities: [ entities: [
@@ -391,7 +373,7 @@ let newSchema = CoreStoreSchema(
Entity<Person>("Person") Entity<Person>("Person")
] ]
) )
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
schemaHistory: SchemaHistory( schemaHistory: SchemaHistory(
legacySchema + [newSchema], legacySchema + [newSchema],
migrationChain: ["MyAppModel", "MyAppModelV2", "MyAppModelV3", "MyAppModelV4", "V1"] migrationChain: ["MyAppModel", "MyAppModelV2", "MyAppModelV3", "MyAppModelV4", "V1"]
@@ -427,7 +409,7 @@ enum V1 {
} }
} }
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
CoreStoreSchema( CoreStoreSchema(
modelVersion: "V1", modelVersion: "V1",
entities: [ entities: [
@@ -533,7 +515,7 @@ Sometimes migrations are huge and you may want prior information so your app cou
```swift ```swift
do { do {
let storage = SQLiteStorage(fileName: "MyStore.sqlite") let storage = SQLiteStorage(fileName: "MyStore.sqlite")
let migrationTypes: [MigrationType] = try CoreStore.requiredMigrationsForStorage(storage) let migrationTypes: [MigrationType] = try dataStack.requiredMigrationsForStorage(storage)
if migrationTypes.count > 1 if migrationTypes.count > 1
|| (migrationTypes.filter { $0.isHeavyweightMigration }.count) > 0 { || (migrationTypes.filter { $0.isHeavyweightMigration }.count) > 0 {
// ... will migrate more than once. Show special waiting screen // ... will migrate more than once. Show special waiting screen
@@ -544,7 +526,7 @@ do {
else { else {
// ... Do nothing // ... Do nothing
} }
CoreStore.addStorage(storage, completion: { /* ... */ }) dataStack.addStorage(storage, completion: { /* ... */ })
} }
catch { catch {
// ... either inspection of the store failed, or if no mapping model was found/inferred // ... either inspection of the store failed, or if no mapping model was found/inferred
@@ -633,7 +615,7 @@ dataStack.perform(
``` ```
or for the default stack, directly from `CoreStore`: or for the default stack, directly from `CoreStore`:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
// make changes // make changes
}, },
@@ -668,7 +650,7 @@ The examples above use `perform(asynchronous:...)`, but there are actually 3 typ
#### Asynchronous transactions #### Asynchronous transactions
are spawned from `perform(asynchronous:...)`. This method returns immediately and executes its closure from a background serial queue. The return value for the closure is declared as a generic type, so any value returned from the closure can be passed to the completion result: are spawned from `perform(asynchronous:...)`. This method returns immediately and executes its closure from a background serial queue. The return value for the closure is declared as a generic type, so any value returned from the closure can be passed to the completion result:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Bool in asynchronous: { (transaction) -> Bool in
// make changes // make changes
return transaction.hasChanges return transaction.hasChanges
@@ -683,7 +665,7 @@ CoreStore.perform(
``` ```
The success and failure can also be declared as separate handlers: The success and failure can also be declared as separate handlers:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Int in asynchronous: { (transaction) -> Int in
// make changes // make changes
return transaction.delete(objects) return transaction.delete(objects)
@@ -704,7 +686,7 @@ Transactions created from `perform(asynchronous:...)` are instances of `Asynchro
#### Synchronous transactions #### Synchronous transactions
are created from `perform(synchronous:...)`. While the syntax is similar to its asynchronous counterpart, `perform(synchronous:...)` waits for its transaction block to complete before returning: are created from `perform(synchronous:...)`. While the syntax is similar to its asynchronous counterpart, `perform(synchronous:...)` waits for its transaction block to complete before returning:
```swift ```swift
let hasChanges = CoreStore.perform( let hasChanges = dataStack.perform(
synchronous: { (transaction) -> Bool in synchronous: { (transaction) -> Bool in
// make changes // make changes
return transaction.hasChanges return transaction.hasChanges
@@ -717,14 +699,14 @@ Since `perform(synchronous:...)` technically blocks two queues (the caller's que
By default, `perform(synchronous:...)` will wait for observers such as `ListMonitor`s to be notified before the method returns. This may cause deadlocks, especially if you are calling this from the main thread. To reduce this risk, you may try to set the `waitForAllObservers:` parameter to `false`. Doing so tells the `SynchronousDataTransaction` to block only until it completes saving. It will not wait for other context's to receive those changes. This reduces deadlock risk but may have surprising side-effects: By default, `perform(synchronous:...)` will wait for observers such as `ListMonitor`s to be notified before the method returns. This may cause deadlocks, especially if you are calling this from the main thread. To reduce this risk, you may try to set the `waitForAllObservers:` parameter to `false`. Doing so tells the `SynchronousDataTransaction` to block only until it completes saving. It will not wait for other context's to receive those changes. This reduces deadlock risk but may have surprising side-effects:
```swift ```swift
CoreStore.perform( dataStack.perform(
synchronous: { (transaction) in synchronous: { (transaction) in
let person = transaction.create(Into<Person>()) let person = transaction.create(Into<Person>())
person.name = "John" person.name = "John"
}, },
waitForAllObservers: false waitForAllObservers: false
) )
let newPerson = CoreStore.fetchOne(From<Person>.where(\.name == "John")) let newPerson = dataStack.fetchOne(From<Person>.where(\.name == "John"))
// newPerson may be nil! // newPerson may be nil!
// The DataStack may have not yet received the update notification. // The DataStack may have not yet received the update notification.
``` ```
@@ -733,7 +715,7 @@ Due to this complicated nature of synchronous transactions, if your app has very
#### Unsafe transactions #### Unsafe transactions
are special in that they do not enclose updates within a closure: are special in that they do not enclose updates within a closure:
```swift ```swift
let transaction = CoreStore.beginUnsafe() let transaction = dataStack.beginUnsafe()
// make changes // make changes
downloadJSONWithCompletion({ (json) -> Void in downloadJSONWithCompletion({ (json) -> Void in
@@ -779,7 +761,7 @@ Note that if you do explicitly specify the configuration name, CoreStore will on
After creating an object from the transaction, you can simply update its properties as normal: After creating an object from the transaction, you can simply update its properties as normal:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let person = transaction.create(Into<MyPersonEntity>()) let person = transaction.create(Into<MyPersonEntity>())
person.name = "John Smith" person.name = "John Smith"
@@ -790,7 +772,7 @@ CoreStore.perform(
``` ```
To update an existing object, fetch the object's instance from the transaction: To update an existing object, fetch the object's instance from the transaction:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let person = try transaction.fetchOne( let person = try transaction.fetchOne(
From<MyPersonEntity>() From<MyPersonEntity>()
@@ -807,7 +789,7 @@ CoreStore.perform(
```swift ```swift
let jane: MyPersonEntity = // ... let jane: MyPersonEntity = // ...
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
// WRONG: jane.age = jane.age + 1 // WRONG: jane.age = jane.age + 1
// RIGHT: // RIGHT:
@@ -822,7 +804,7 @@ This is also true when updating an object's relationships. Make sure that the ob
let jane: MyPersonEntity = // ... let jane: MyPersonEntity = // ...
let john: MyPersonEntity = // ... let john: MyPersonEntity = // ...
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
// WRONG: jane.friends = [john] // WRONG: jane.friends = [john]
// RIGHT: // RIGHT:
@@ -840,7 +822,7 @@ Deleting an object is simpler because you can tell a transaction to delete an ob
```swift ```swift
let john: MyPersonEntity = // ... let john: MyPersonEntity = // ...
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
transaction.delete(john) transaction.delete(john)
}, },
@@ -852,7 +834,7 @@ or several objects at once:
let john: MyPersonEntity = // ... let john: MyPersonEntity = // ...
let jane: MyPersonEntity = // ... let jane: MyPersonEntity = // ...
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
try transaction.delete(john, jane) try transaction.delete(john, jane)
// try transaction.delete([john, jane]) is also allowed // try transaction.delete([john, jane]) is also allowed
@@ -862,7 +844,7 @@ CoreStore.perform(
``` ```
If you do not have references yet to the objects to be deleted, transactions have a `deleteAll(...)` method you can pass a query to: If you do not have references yet to the objects to be deleted, transactions have a `deleteAll(...)` method you can pass a query to:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
try transaction.deleteAll( try transaction.deleteAll(
From<MyPersonEntity>() From<MyPersonEntity>()
@@ -879,7 +861,7 @@ Always remember that the `DataStack` and individual transactions manage differen
```swift ```swift
let jane: MyPersonEntity = // ... let jane: MyPersonEntity = // ...
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let jane = transaction.edit(jane)! let jane = transaction.edit(jane)!
jane.age = jane.age + 1 jane.age = jane.age + 1
@@ -891,14 +873,14 @@ But `CoreStore`, `DataStack` and `BaseDataTransaction` have a very flexible `fet
```swift ```swift
let jane: MyPersonEntity = // ... let jane: MyPersonEntity = // ...
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> MyPersonEntity in asynchronous: { (transaction) -> MyPersonEntity in
let jane = transaction.fetchExisting(jane)! // instance for transaction let jane = transaction.fetchExisting(jane)! // instance for transaction
jane.age = jane.age + 1 jane.age = jane.age + 1
return jane return jane
}, },
success: { (transactionJane) in success: { (transactionJane) in
let jane = CoreStore.fetchExisting(transactionJane)! // instance for DataStack let jane = dataStack.fetchExisting(transactionJane)! // instance for DataStack
print(jane.age) print(jane.age)
}, },
failure: { (error) in failure: { (error) in
@@ -910,7 +892,7 @@ CoreStore.perform(
```swift ```swift
var peopleIDs: [NSManagedObjectID] = // ... var peopleIDs: [NSManagedObjectID] = // ...
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let jane = try transaction.fetchOne( let jane = try transaction.fetchOne(
From<MyPersonEntity>() From<MyPersonEntity>()
@@ -934,7 +916,7 @@ person.age = json["age"] as? NSNumber
``` ```
If you have many attributes, you don't want to keep repeating this mapping everytime you want to import data. CoreStore lets you write the data mapping code just once, and all you have to do is call `importObject(...)` or `importUniqueObject(...)` through `BaseDataTransaction` subclasses: If you have many attributes, you don't want to keep repeating this mapping everytime you want to import data. CoreStore lets you write the data mapping code just once, and all you have to do is call `importObject(...)` or `importUniqueObject(...)` through `BaseDataTransaction` subclasses:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let json: [String: Any] = // ... let json: [String: Any] = // ...
try! transaction.importObject( try! transaction.importObject(
@@ -976,7 +958,7 @@ typealias ImportSource = [String: Any]
``` ```
This lets us call `importObject(_:source:)` with any `[String: Any]` type as the argument to `source`: This lets us call `importObject(_:source:)` with any `[String: Any]` type as the argument to `source`:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let json: [String: Any] = // ... let json: [String: Any] = // ...
try! transaction.importObject( try! transaction.importObject(
@@ -998,7 +980,7 @@ func didInsert(from source: ImportSource, in transaction: BaseDataTransaction) t
``` ```
Transactions also let you import multiple objects at once using the `importObjects(_:sourceArray:)` method: Transactions also let you import multiple objects at once using the `importObjects(_:sourceArray:)` method:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let jsonArray: [[String: Any]] = // ... let jsonArray: [[String: Any]] = // ...
try! transaction.importObjects( try! transaction.importObjects(
@@ -1025,7 +1007,7 @@ func didInsert(from source: ImportSource, in transaction: BaseDataTransaction) t
``` ```
Doing so can let you abandon an invalid transaction immediately: Doing so can let you abandon an invalid transaction immediately:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let jsonArray: [[String: Any]] = // ... let jsonArray: [[String: Any]] = // ...
@@ -1080,7 +1062,7 @@ For `ImportableUniqueObject`, the extraction and assignment of values should be
You can then create/update an object by calling a transaction's `importUniqueObject(...)` method: You can then create/update an object by calling a transaction's `importUniqueObject(...)` method:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let json: [String: Any] = // ... let json: [String: Any] = // ...
try! transaction.importUniqueObject( try! transaction.importUniqueObject(
@@ -1095,7 +1077,7 @@ CoreStore.perform(
or multiple objects at once with the `importUniqueObjects(...)` method: or multiple objects at once with the `importUniqueObjects(...)` method:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let jsonArray: [[String: AnyObject]] = // ... let jsonArray: [[String: AnyObject]] = // ...
try! transaction.importUniqueObjects( try! transaction.importUniqueObjects(
@@ -1125,17 +1107,17 @@ Before we dive in, be aware that CoreStore distinguishes between *fetching* and
#### `From` clause #### `From` clause
The search conditions for fetches and queries are specified using *clauses*. All fetches and queries require a `From` clause that indicates the target entity type: The search conditions for fetches and queries are specified using *clauses*. All fetches and queries require a `From` clause that indicates the target entity type:
```swift ```swift
let people = try CoreStore.fetchAll(From<MyPersonEntity>()) let people = try dataStack.fetchAll(From<MyPersonEntity>())
``` ```
`people` in the example above will be of type `[MyPersonEntity]`. The `From<MyPersonEntity>()` clause indicates a fetch to all persistent stores that `MyPersonEntity` belong to. `people` in the example above will be of type `[MyPersonEntity]`. The `From<MyPersonEntity>()` clause indicates a fetch to all persistent stores that `MyPersonEntity` belong to.
If the entity exists in multiple configurations and you need to only search from a particular configuration, indicate in the `From` clause the configuration name for the destination persistent store: If the entity exists in multiple configurations and you need to only search from a particular configuration, indicate in the `From` clause the configuration name for the destination persistent store:
```swift ```swift
let people = try CoreStore.fetchAll(From<MyPersonEntity>("Config1")) // ignore objects in persistent stores other than the "Config1" configuration let people = try dataStack.fetchAll(From<MyPersonEntity>("Config1")) // ignore objects in persistent stores other than the "Config1" configuration
``` ```
or if the persistent store is the auto-generated "Default" configuration, specify `nil`: or if the persistent store is the auto-generated "Default" configuration, specify `nil`:
```swift ```swift
let person = try CoreStore.fetchAll(From<MyPersonEntity>(nil)) let person = try dataStack.fetchAll(From<MyPersonEntity>(nil))
``` ```
Now we know how to use a `From` clause, let's move on to fetching and querying. Now we know how to use a `From` clause, let's move on to fetching and querying.
@@ -1155,11 +1137,11 @@ Each method's purpose is straightforward, but we need to understand how to set t
The `Where` clause is CoreStore's `NSPredicate` wrapper. It specifies the search filter to use when fetching (or querying). It implements all initializers that `NSPredicate` does (except for `-predicateWithBlock:`, which Core Data does not support): The `Where` clause is CoreStore's `NSPredicate` wrapper. It specifies the search filter to use when fetching (or querying). It implements all initializers that `NSPredicate` does (except for `-predicateWithBlock:`, which Core Data does not support):
```swift ```swift
var people = try CoreStore.fetchAll( var people = try dataStack.fetchAll(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Where<MyPersonEntity>("%K > %d", "age", 30) // string format initializer Where<MyPersonEntity>("%K > %d", "age", 30) // string format initializer
) )
people = try CoreStore.fetchAll( people = try dataStack.fetchAll(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Where<MyPersonEntity>(true) // boolean initializer Where<MyPersonEntity>(true) // boolean initializer
) )
@@ -1167,21 +1149,21 @@ people = try CoreStore.fetchAll(
If you do have an existing `NSPredicate` instance already, you can pass that to `Where` as well: If you do have an existing `NSPredicate` instance already, you can pass that to `Where` as well:
```swift ```swift
let predicate = NSPredicate(...) let predicate = NSPredicate(...)
var people = CoreStore.fetchAll( var people = dataStack.fetchAll(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Where<MyPersonEntity>(predicate) // predicate initializer Where<MyPersonEntity>(predicate) // predicate initializer
) )
``` ```
Starting CoreStore 5.0, `Where` clauses became more type-safe and are now generic types. To avoid verbose repetition of the generic object type, fetch methods now support **Fetch Chain builders**. We can also use Swift's Smart KeyPaths as the `Where` clause expression: Starting CoreStore 5.0, `Where` clauses became more type-safe and are now generic types. To avoid verbose repetition of the generic object type, fetch methods now support **Fetch Chain builders**. We can also use Swift's Smart KeyPaths as the `Where` clause expression:
```swift ```swift
var people = try CoreStore.fetchAll( var people = try dataStack.fetchAll(
From<MyPersonEntity>() From<MyPersonEntity>()
.where(\.age > 30) // Type-safe! .where(\.age > 30) // Type-safe!
) )
``` ```
`Where` clauses also implement the `&&`, `||`, and `!` logic operators, so you can provide logical conditions without writing too much `AND`, `OR`, and `NOT` strings: `Where` clauses also implement the `&&`, `||`, and `!` logic operators, so you can provide logical conditions without writing too much `AND`, `OR`, and `NOT` strings:
```swift ```swift
var people = try CoreStore.fetchAll( var people = try dataStack.fetchAll(
From<MyPersonEntity>() From<MyPersonEntity>()
.where(\.age > 30 && \.gender == "M") .where(\.age > 30 && \.gender == "M")
) )
@@ -1192,7 +1174,7 @@ If you do not provide a `Where` clause, all objects that belong to the specified
The `OrderBy` clause is CoreStore's `NSSortDescriptor` wrapper. Use it to specify attribute keys in which to sort the fetch (or query) results with. The `OrderBy` clause is CoreStore's `NSSortDescriptor` wrapper. Use it to specify attribute keys in which to sort the fetch (or query) results with.
```swift ```swift
var mostValuablePeople = try CoreStore.fetchAll( var mostValuablePeople = try dataStack.fetchAll(
From<MyPersonEntity>(), From<MyPersonEntity>(),
OrderBy<MyPersonEntity>(.descending("rating"), .ascending("surname")) OrderBy<MyPersonEntity>(.descending("rating"), .ascending("surname"))
) )
@@ -1200,7 +1182,7 @@ var mostValuablePeople = try CoreStore.fetchAll(
As seen above, `OrderBy` accepts a list of `SortKey` enumeration values, which can be either `.ascending` or `.descending`. As seen above, `OrderBy` accepts a list of `SortKey` enumeration values, which can be either `.ascending` or `.descending`.
As with `Where` clauses, CoreStore 5.0 turned `OrderBy` clauses into generic types. To avoid verbose repetition of the generic object type, fetch methods now support **Fetch Chain builders**. We can also use Swift's Smart KeyPaths as the `OrderBy` clause expression: As with `Where` clauses, CoreStore 5.0 turned `OrderBy` clauses into generic types. To avoid verbose repetition of the generic object type, fetch methods now support **Fetch Chain builders**. We can also use Swift's Smart KeyPaths as the `OrderBy` clause expression:
```swift ```swift
var people = try CoreStore.fetchAll( var people = try dataStack.fetchAll(
From<MyPersonEntity>() From<MyPersonEntity>()
.orderBy(.descending(\.rating), .ascending(\.surname)) // Type-safe! .orderBy(.descending(\.rating), .ascending(\.surname)) // Type-safe!
) )
@@ -1212,7 +1194,7 @@ var orderBy = OrderBy<MyPersonEntity>(.descending(\.rating))
if sortFromYoungest { if sortFromYoungest {
orderBy += OrderBy(.ascending(\.age)) orderBy += OrderBy(.ascending(\.age))
} }
var mostValuablePeople = try CoreStore.fetchAll( var mostValuablePeople = try dataStack.fetchAll(
From<MyPersonEntity>(), From<MyPersonEntity>(),
orderBy orderBy
) )
@@ -1222,7 +1204,7 @@ var mostValuablePeople = try CoreStore.fetchAll(
The `Tweak` clause lets you, uh, *tweak* the fetch (or query). `Tweak` exposes the `NSFetchRequest` in a closure where you can make changes to its properties: The `Tweak` clause lets you, uh, *tweak* the fetch (or query). `Tweak` exposes the `NSFetchRequest` in a closure where you can make changes to its properties:
```swift ```swift
var people = try CoreStore.fetchAll( var people = try dataStack.fetchAll(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Where<MyPersonEntity>("age > %d", 30), Where<MyPersonEntity>("age > %d", 30),
OrderBy<MyPersonEntity>(.ascending("surname")), OrderBy<MyPersonEntity>(.ascending("surname")),
@@ -1235,7 +1217,7 @@ var people = try CoreStore.fetchAll(
``` ```
`Tweak` also supports **Fetch Chain builders**: `Tweak` also supports **Fetch Chain builders**:
```swift ```swift
var people = try CoreStore.fetchAll( var people = try dataStack.fetchAll(
From<MyPersonEntity>(), From<MyPersonEntity>(),
.where(\.age > 30) .where(\.age > 30)
.orderBy(.ascending(\.surname)) .orderBy(.ascending(\.surname))
@@ -1266,7 +1248,7 @@ Setting up the `From`, `Where`, `OrderBy`, and `Tweak` clauses is similar to how
The `Select<T>` clause specifies the target attribute/aggregate key, as well as the expected return type: The `Select<T>` clause specifies the target attribute/aggregate key, as well as the expected return type:
```swift ```swift
let johnsAge = try CoreStore.queryValue( let johnsAge = try dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select<Int>("age"), Select<Int>("age"),
Where("name == %@", "John Smith") Where("name == %@", "John Smith")
@@ -1276,14 +1258,14 @@ The example above queries the "age" property for the first object that matches t
For `queryAttributes(...)`, only `NSDictionary` is valid for `Select`, thus you are allowed to omit the generic type: For `queryAttributes(...)`, only `NSDictionary` is valid for `Select`, thus you are allowed to omit the generic type:
```swift ```swift
let allAges = try CoreStore.queryAttributes( let allAges = try dataStack.queryAttributes(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select("age") Select("age")
) )
``` ```
Starting CoreStore 5.0, query methods now support **Query Chain builders**. We can also use Swift's Smart KeyPaths to use in the expressions: Starting CoreStore 5.0, query methods now support **Query Chain builders**. We can also use Swift's Smart KeyPaths to use in the expressions:
```swift ```swift
let johnsAge = try CoreStore.queryValue( let johnsAge = try dataStack.queryValue(
From<MyPersonEntity>() From<MyPersonEntity>()
.select(\.age) // binds the result to Int .select(\.age) // binds the result to Int
.where(\.name == "John Smith") .where(\.name == "John Smith")
@@ -1298,7 +1280,7 @@ If you only need a value for a particular attribute, you can just specify the ke
- `.sum(...)` - `.sum(...)`
```swift ```swift
let oldestAge = try CoreStore.queryValue( let oldestAge = try dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select<Int>(.maximum("age")) Select<Int>(.maximum("age"))
) )
@@ -1306,7 +1288,7 @@ let oldestAge = try CoreStore.queryValue(
For `queryAttributes(...)` which returns an array of dictionaries, you can specify multiple attributes/aggregates to `Select`: For `queryAttributes(...)` which returns an array of dictionaries, you can specify multiple attributes/aggregates to `Select`:
```swift ```swift
let personJSON = try CoreStore.queryAttributes( let personJSON = try dataStack.queryAttributes(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select("name", "age") Select("name", "age")
) )
@@ -1326,7 +1308,7 @@ let personJSON = try CoreStore.queryAttributes(
``` ```
You can also include an aggregate as well: You can also include an aggregate as well:
```swift ```swift
let personJSON = try CoreStore.queryAttributes( let personJSON = try dataStack.queryAttributes(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select("name", .count("friends")) Select("name", .count("friends"))
) )
@@ -1346,7 +1328,7 @@ which returns:
``` ```
The `"count(friends)"` key name was automatically used by CoreStore, but you can specify your own key alias if you need: The `"count(friends)"` key name was automatically used by CoreStore, but you can specify your own key alias if you need:
```swift ```swift
let personJSON = try CoreStore.queryAttributes( let personJSON = try dataStack.queryAttributes(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select("name", .count("friends", as: "friendsCount")) Select("name", .count("friends", as: "friendsCount"))
) )
@@ -1369,7 +1351,7 @@ which now returns:
The `GroupBy` clause lets you group results by a specified attribute/aggregate. This is useful only for `queryAttributes(...)` since `queryValue(...)` just returns the first value. The `GroupBy` clause lets you group results by a specified attribute/aggregate. This is useful only for `queryAttributes(...)` since `queryValue(...)` just returns the first value.
```swift ```swift
let personJSON = try CoreStore.queryAttributes( let personJSON = try dataStack.queryAttributes(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select("age", .count("age", as: "count")), Select("age", .count("age", as: "count")),
GroupBy("age") GroupBy("age")
@@ -1377,7 +1359,7 @@ let personJSON = try CoreStore.queryAttributes(
``` ```
Starting CoreStore 5.0, `GroupBy` clauses are now also generic types and now support **Query Chain builders**. We can also use Swift's Smart KeyPaths to use in the expressions: Starting CoreStore 5.0, `GroupBy` clauses are now also generic types and now support **Query Chain builders**. We can also use Swift's Smart KeyPaths to use in the expressions:
```swift ```swift
let personJSON = try CoreStore.queryAttributes( let personJSON = try dataStack.queryAttributes(
From<MyPersonEntity>() From<MyPersonEntity>()
.select(.attribute(\.age), .count(\.age, as: "count")) .select(.attribute(\.age), .count(\.age, as: "count"))
.groupBy(\.age) .groupBy(\.age)
@@ -1407,9 +1389,9 @@ public protocol CoreStoreLogger {
func abort(message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) func abort(message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString)
} }
``` ```
Implement this protocol with your custom class then pass the instance to `CoreStore.logger`: Implement this protocol with your custom class then pass the instance to `CoreStoreDefaults.logger`:
```swift ```swift
CoreStore.logger = MyLogger() CoreStoreDefaults.logger = MyLogger()
``` ```
Doing so channels all logging calls to your logger. Doing so channels all logging calls to your logger.
@@ -1479,7 +1461,7 @@ class MyViewController: UIViewController, ObjectObserver {
We then need to keep an `ObjectMonitor` instance and register our `ObjectObserver` as an observer: We then need to keep an `ObjectMonitor` instance and register our `ObjectObserver` as an observer:
```swift ```swift
let person: MyPersonEntity = // ... let person: MyPersonEntity = // ...
self.monitor = CoreStore.monitorObject(person) self.monitor = dataStack.monitorObject(person)
self.monitor.addObserver(self) self.monitor.addObserver(self)
``` ```
The controller will then notify our observer whenever the object's attributes change. You can add multiple `ObjectObserver`s to a single `ObjectMonitor` without any problem. This means you can just share around the `ObjectMonitor` instance to different screens without problem. The controller will then notify our observer whenever the object's attributes change. You can add multiple `ObjectObserver`s to a single `ObjectMonitor` without any problem. This means you can just share around the `ObjectMonitor` instance to different screens without problem.
@@ -1526,7 +1508,7 @@ Including `ListObserver`, there are 3 observer protocols you can implement depen
We then need to create a `ListMonitor` instance and register our `ListObserver` as an observer: We then need to create a `ListMonitor` instance and register our `ListObserver` as an observer:
```swift ```swift
self.monitor = CoreStore.monitorList( self.monitor = dataStack.monitorList(
From<MyPersonEntity>() From<MyPersonEntity>()
.where(\.age > 30) .where(\.age > 30)
.orderBy(.ascending(\.name)) .orderBy(.ascending(\.name))
@@ -1545,7 +1527,7 @@ let firstPerson = self.monitor[0]
If the list needs to be grouped into sections, create the `ListMonitor` instance with the `monitorSectionedList(...)` method and a `SectionBy` clause: If the list needs to be grouped into sections, create the `ListMonitor` instance with the `monitorSectionedList(...)` method and a `SectionBy` clause:
```swift ```swift
self.monitor = CoreStore.monitorSectionedList( self.monitor = dataStack.monitorSectionedList(
From<MyPersonEntity>() From<MyPersonEntity>()
.sectionBy(\.age) .sectionBy(\.age)
.where(\.gender == "M") .where(\.gender == "M")
@@ -1557,7 +1539,7 @@ A list controller created this way will group the objects by the attribute key i
The `SectionBy` clause can also be passed a closure to transform the section name into a displayable string: The `SectionBy` clause can also be passed a closure to transform the section name into a displayable string:
```swift ```swift
self.monitor = CoreStore.monitorSectionedList( self.monitor = dataStack.monitorSectionedList(
From<MyPersonEntity>() From<MyPersonEntity>()
.sectionBy(\.age) { (sectionName) -> String? in .sectionBy(\.age) { (sectionName) -> String? in
"\(sectionName) years old" "\(sectionName) years old"
@@ -1590,7 +1572,7 @@ All CoreStore types are still written in pure Swift, but most core types have Ob
<tr><th>Swift</th><th>Objective-C</th></tr> <tr><th>Swift</th><th>Objective-C</th></tr>
<tr> <tr>
<td><pre lang=swift> <td><pre lang=swift>
try CoreStore.addStorageAndWait(SQLiteStore.self) try dataStack.addStorageAndWait(SQLiteStore.self)
</pre></td> </pre></td>
<td><pre lang=objc> <td><pre lang=objc>
NSError *error NSError *error
@@ -1599,7 +1581,7 @@ NSError *error
</tr> </tr>
<tr> <tr>
<td><pre lang=swift> <td><pre lang=swift>
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) in 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`: For example, you may have a new, modern Swift class that holds a `ListMonitor`:
```swift ```swift
class MyViewController: UIViewController { class MyViewController: UIViewController {
let monitor = CoreStore.monitorList(From<MyEntity>(), ...) let monitor = dataStack.monitorList(From<MyEntity>(), ...)
// ... // ...
} }
``` ```
@@ -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`: When you need to instantiate this class from Swift, you just call `bridgeToObjectiveC`:
```swift ```swift
class MyViewController: UIViewController { class MyViewController: UIViewController {
let monitor = CoreStore.monitorList(From<MyEntity>(), ...) let monitor = dataStack.monitorList(From<MyEntity>(), ...)
func showOldController() { func showOldController() {
let controller = MYOldViewController(monitor: self.monitor.bridgeToObjectiveC) let controller = MYOldViewController(monitor: self.monitor.bridgeToObjectiveC)
self.presentViewController(controller, animated: true, completion: nil) 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`: To tell the `DataStack` about these types, add all `CoreStoreObject`s' entities to a `CoreStoreSchema`:
```swift ```swift
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
CoreStoreSchema( CoreStoreSchema(
modelVersion: "V1", modelVersion: "V1",
entities: [ 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.** 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`: These special properties' values can be accessed or mutated using `.value`:
```swift ```swift
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) in asynchronous: { (transaction) in
let dog: Dog = transaction.fetchOne(From<Dog>())! let dog: Dog = transaction.fetchOne(From<Dog>())!
// ... // ...
@@ -1755,7 +1737,7 @@ let keyPath: String = Dog.keyPath { $0.nickname }
``` ```
as well as `Where` and `OrderBy` clauses as well as `Where` and `OrderBy` clauses
```swift ```swift
let puppies = try CoreStore.fetchAll( let puppies = try dataStack.fetchAll(
From<Dog>() From<Dog>()
.where(\.age < 1) .where(\.age < 1)
.orderBy(.ascending(\.age)) .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: You can also get this hash after the `DataStack` has been fully set up by printing to the console:
```swift ```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: 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 ### Install with CocoaPods
In your `Podfile`, add In your `Podfile`, add
``` ```
pod 'CoreStore', '~> 6.3' pod 'CoreStore', '~> 7.0'
``` ```
and run and run
``` ```
@@ -1822,7 +1804,7 @@ This installs CoreStore as a framework. Declare `import CoreStore` in your swift
### Install with Carthage ### Install with Carthage
In your `Cartfile`, add In your `Cartfile`, add
``` ```
github "JohnEstropia/CoreStore" >= 6.3.0 github "JohnEstropia/CoreStore" >= 7.0.0
``` ```
and run and run
``` ```
@@ -1833,7 +1815,7 @@ This installs CoreStore as a framework. Declare `import CoreStore` in your swift
#### Install with Swift Package Manager: #### Install with Swift Package Manager:
```swift ```swift
dependencies: [ 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. Declare `import CoreStore` in your swift file to use the library.

View File

@@ -30,7 +30,7 @@ import CoreData
// MARK: - AsynchronousDataTransaction // 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 { public final class AsynchronousDataTransaction: BaseDataTransaction {

View File

@@ -38,7 +38,7 @@ extension CSCoreStore {
@objc @objc
public static var modelVersion: String { public static var modelVersion: String {
return CoreStore.modelVersion return self.defaultStack.modelVersion
} }
/** /**
@@ -47,7 +47,7 @@ extension CSCoreStore {
@objc @objc
public static func entityTypesByNameForType(_ type: NSManagedObject.Type) -> [EntityName: NSManagedObject.Type] { 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 @objc
public static func entityDescriptionForClass(_ type: NSManagedObject.Type) -> NSEntityDescription? { public static func entityDescriptionForClass(_ type: NSManagedObject.Type) -> NSEntityDescription? {
return CoreStore.entityDescription(for: type) return self.defaultStack.bridgeToSwift.entityDescription(for: type)
} }
/** /**

View File

@@ -65,7 +65,7 @@ extension CSCoreStore {
return bridge { return bridge {
CoreStore.beginUnsafe() self.defaultStack.bridgeToSwift.beginUnsafe()
} }
} }
@@ -80,7 +80,7 @@ extension CSCoreStore {
return bridge { return bridge {
CoreStore.beginUnsafe(supportsUndo: supportsUndo) self.defaultStack.bridgeToSwift.beginUnsafe(supportsUndo: supportsUndo)
} }
} }
@@ -90,6 +90,6 @@ extension CSCoreStore {
@objc @objc
public static func refreshAndMergeAllObjects() { public static func refreshAndMergeAllObjects() {
CoreStore.refreshAndMergeAllObjects() self.defaultStack.refreshAndMergeAllObjects()
} }
} }

View File

@@ -46,8 +46,8 @@ public final class CSCoreStore: NSObject {
@objc @objc
public static var defaultStack: CSDataStack { public static var defaultStack: CSDataStack {
get { return Shared.defaultStack.bridgeToObjectiveC } get { return CoreStoreDefaults.dataStack.bridgeToObjectiveC }
set { Shared.defaultStack = newValue.bridgeToSwift } set { CoreStoreDefaults.dataStack = newValue.bridgeToSwift }
} }

View File

@@ -35,7 +35,7 @@ extension Internals {
@inline(__always) @inline(__always)
internal static func log(_ level: LogLevel, message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) { 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, level: level,
message: message, message: message,
fileName: fileName, fileName: fileName,
@@ -47,7 +47,7 @@ extension Internals {
@inline(__always) @inline(__always)
internal static func log(_ error: CoreStoreError, _ message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) { 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, error: error,
message: message, message: message,
fileName: fileName, fileName: fileName,
@@ -59,7 +59,7 @@ extension Internals {
@inline(__always) @inline(__always)
internal static func assert( _ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) { 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(), condition(),
message: message(), message: message(),
fileName: fileName, fileName: fileName,
@@ -71,7 +71,7 @@ extension Internals {
@inline(__always) @inline(__always)
internal static func abort(_ message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) -> Never { internal static func abort(_ message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) -> Never {
Shared.logger.abort( CoreStoreDefaults.logger.abort(
message, message,
fileName: fileName, fileName: fileName,
lineNumber: lineNumber, lineNumber: lineNumber,

View File

@@ -33,9 +33,9 @@ import CoreData
extension CoreStore { 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"), InMemoryStore(configuration: "Config1"),
completion: { result in completion: { result in
switch result { switch result {
@@ -50,13 +50,13 @@ extension CoreStore {
*/ */
public static func addStorage<T>(_ storage: T, completion: @escaping (SetupResult<T>) -> Void) { public static func addStorage<T>(_ storage: T, completion: @escaping (SetupResult<T>) -> 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"), SQLiteStore(fileName: "core_data.sqlite", configuration: "Config1"),
completion: { result in completion: { result in
switch result { switch result {
@@ -72,11 +72,11 @@ extension CoreStore {
*/ */
public static func addStorage<T: LocalStorage>(_ storage: T, completion: @escaping (SetupResult<T>) -> Void) -> Progress? { public static func addStorage<T: LocalStorage>(_ storage: T, completion: @escaping (SetupResult<T>) -> 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( guard let storage = ICloudStore(
ubiquitousContentName: "MyAppCloudData", ubiquitousContentName: "MyAppCloudData",
@@ -104,11 +104,11 @@ extension CoreStore {
*/ */
public static func addStorage<T: CloudStorage>(_ storage: T, completion: @escaping (SetupResult<T>) -> Void) { public static func addStorage<T: CloudStorage>(_ storage: T, completion: @escaping (SetupResult<T>) -> 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 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. - 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<T: LocalStorage>(_ storage: T, completion: @escaping (MigrationResult) -> Void) throws -> Progress? { public static func upgradeStorageIfNeeded<T: LocalStorage>(_ 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 - parameter storage: the local storage
- throws: a `CoreStoreError` value indicating the failure - throws: a `CoreStoreError` value indicating the failure
@@ -129,6 +129,6 @@ extension CoreStore {
*/ */
public static func requiredMigrationsForStorage<T: LocalStorage>(_ storage: T) throws -> [MigrationType] { public static func requiredMigrationsForStorage<T: LocalStorage>(_ storage: T) throws -> [MigrationType] {
return try Shared.defaultStack.requiredMigrationsForStorage(storage) return try CoreStoreDefaults.dataStack.requiredMigrationsForStorage(storage)
} }
} }

View File

@@ -34,18 +34,18 @@ import CoreData
extension CoreStore { 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 - parameter object: the `DynamicObject` to observe changes from
- returns: an `ObjectMonitor` that monitors changes to `object` - returns: an `ObjectMonitor` that monitors changes to `object`
*/ */
public static func monitorObject<O: DynamicObject>(_ object: O) -> ObjectMonitor<O> { public static func monitorObject<O: DynamicObject>(_ object: O) -> ObjectMonitor<O> {
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 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. - 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> ListMonitor<D> { public static func monitorList<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> ListMonitor<D> {
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 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. - 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> ListMonitor<D> { public static func monitorList<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> ListMonitor<D> {
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. 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<MyPersonEntity>() From<MyPersonEntity>()
.where(\.age > 18) .where(\.age > 18)
.orderBy(.ascending(\.age)) .orderBy(.ascending(\.age))
@@ -82,11 +82,11 @@ extension CoreStore {
*/ */
public static func monitorList<B: FetchChainableBuilderType>(_ clauseChain: B) -> ListMonitor<B.ObjectType> { public static func monitorList<B: FetchChainableBuilderType>(_ clauseChain: B) -> ListMonitor<B.ObjectType> {
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 createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter from: a `From` clause indicating the entity type - parameter from: a `From` clause indicating the entity type
@@ -94,11 +94,11 @@ extension CoreStore {
*/ */
public static func monitorList<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ fetchClauses: FetchClause...) { public static func monitorList<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ 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 createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter from: a `From` clause indicating the entity type - parameter from: a `From` clause indicating the entity type
@@ -106,14 +106,14 @@ extension CoreStore {
*/ */
public static func monitorList<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ fetchClauses: [FetchClause]) { public static func monitorList<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ 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. 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 createAsynchronously: { (monitor) in
self.monitor = monitor self.monitor = monitor
}, },
@@ -127,7 +127,7 @@ extension CoreStore {
*/ */
public static func monitorList<B: FetchChainableBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) { public static func monitorList<B: FetchChainableBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
Shared.defaultStack.monitorList( CoreStoreDefaults.dataStack.monitorList(
createAsynchronously: createAsynchronously, createAsynchronously: createAsynchronously,
clauseChain.from, clauseChain.from,
clauseChain.fetchClauses 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 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. - 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<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) -> ListMonitor<D> { public static func monitorSectionedList<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) -> ListMonitor<D> {
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 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. - 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<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) -> ListMonitor<D> { public static func monitorSectionedList<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) -> ListMonitor<D> {
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. 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<MyPersonEntity>() From<MyPersonEntity>()
.sectionBy(\.age, { "\($0!) years old" }) .sectionBy(\.age, { "\($0!) years old" })
.where(\.age > 18) .where(\.age > 18)
@@ -175,7 +175,7 @@ extension CoreStore {
*/ */
public static func monitorSectionedList<B: SectionMonitorBuilderType>(_ clauseChain: B) -> ListMonitor<B.ObjectType> { public static func monitorSectionedList<B: SectionMonitorBuilderType>(_ clauseChain: B) -> ListMonitor<B.ObjectType> {
return Shared.defaultStack.monitorSectionedList( return CoreStoreDefaults.dataStack.monitorSectionedList(
clauseChain.from, clauseChain.from,
clauseChain.sectionBy, clauseChain.sectionBy,
clauseChain.fetchClauses 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 createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter from: a `From` clause indicating the entity type - parameter from: a `From` clause indicating the entity type
@@ -192,11 +192,11 @@ extension CoreStore {
*/ */
public static func monitorSectionedList<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) { public static func monitorSectionedList<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ sectionBy: SectionBy<D>, _ 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 createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter from: a `From` clause indicating the entity type - parameter from: a `From` clause indicating the entity type
@@ -205,13 +205,13 @@ extension CoreStore {
*/ */
public static func monitorSectionedList<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) { public static func monitorSectionedList<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ sectionBy: SectionBy<D>, _ 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. 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 createAsynchronously: { (monitor) in
self.monitor = monitor self.monitor = monitor
}, },
@@ -226,7 +226,7 @@ extension CoreStore {
*/ */
public static func monitorSectionedList<B: SectionMonitorBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) { public static func monitorSectionedList<B: SectionMonitorBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
Shared.defaultStack.monitorSectionedList( CoreStoreDefaults.dataStack.monitorSectionedList(
createAsynchronously: createAsynchronously, createAsynchronously: createAsynchronously,
clauseChain.from, clauseChain.from,
clauseChain.sectionBy, clauseChain.sectionBy,

View File

@@ -33,51 +33,51 @@ import CoreData
extension CoreStore { 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` - 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. - returns: the `DynamicObject` instance if the object exists in the `DataStack`, or `nil` if not found.
*/ */
public static func fetchExisting<D: DynamicObject>(_ object: D) -> D? { public static func fetchExisting<D: DynamicObject>(_ 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 - parameter objectID: the `NSManagedObjectID` for the object
- returns: the `DynamicObject` instance if the object exists in the `DataStack`, or `nil` if not found. - returns: the `DynamicObject` instance if the object exists in the `DataStack`, or `nil` if not found.
*/ */
public static func fetchExisting<D: DynamicObject>(_ objectID: NSManagedObjectID) -> D? { public static func fetchExisting<D: DynamicObject>(_ 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` - parameter objects: an array of `DynamicObject`s created/fetched outside the `DataStack`
- returns: the `DynamicObject` array for objects that exists in the `DataStack` - returns: the `DynamicObject` array for objects that exists in the `DataStack`
*/ */
public static func fetchExisting<D: DynamicObject, S: Sequence>(_ objects: S) -> [D] where S.Iterator.Element == D { public static func fetchExisting<D: DynamicObject, S: Sequence>(_ 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 - parameter objectIDs: the `NSManagedObjectID` array for the objects
- returns: the `DynamicObject` array for objects that exists in the `DataStack` - returns: the `DynamicObject` array for objects that exists in the `DataStack`
*/ */
public static func fetchExisting<D: DynamicObject, S: Sequence>(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID { public static func fetchExisting<D: DynamicObject, S: Sequence>(_ 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 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. - 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? { public static func fetchOne<D>(_ from: From<D>, _ 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 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. - 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? { public static func fetchOne<D>(_ from: From<D>, _ 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. 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<MyPersonEntity>() From<MyPersonEntity>()
.where(\.age > 18) .where(\.age > 18)
.orderBy(.ascending(\.age)) .orderBy(.ascending(\.age))
@@ -117,11 +117,11 @@ extension CoreStore {
*/ */
public static func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> B.ObjectType? { public static func fetchOne<B: FetchChainableBuilderType>(_ 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 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. - 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] { public static func fetchAll<D>(_ from: From<D>, _ 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 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. - 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] { public static func fetchAll<D>(_ from: From<D>, _ 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. Fetches all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
``` ```
let people = CoreStore.fetchAll( let people = dataStack.fetchAll(
From<MyPersonEntity>() From<MyPersonEntity>()
.where(\.age > 18) .where(\.age > 18)
.orderBy(.ascending(\.age)) .orderBy(.ascending(\.age))
@@ -161,11 +161,11 @@ extension CoreStore {
*/ */
public static func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType] { public static func fetchAll<B: FetchChainableBuilderType>(_ 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 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. - 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int { public static func fetchCount<D>(_ from: From<D>, _ 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 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. - 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int { public static func fetchCount<D>(_ from: From<D>, _ 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. 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<MyPersonEntity>() From<MyPersonEntity>()
.where(\.age > 18) .where(\.age > 18)
.orderBy(.ascending(\.age)) .orderBy(.ascending(\.age))
@@ -205,11 +205,11 @@ extension CoreStore {
*/ */
public static func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int { public static func fetchCount<B: FetchChainableBuilderType>(_ 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 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. - 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { public static func fetchObjectID<D>(_ from: From<D>, _ 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 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. - 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { public static func fetchObjectID<D>(_ from: From<D>, _ 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. 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<MyPersonEntity>() From<MyPersonEntity>()
.where(\.age > 18) .where(\.age > 18)
.orderBy(.ascending(\.age)) .orderBy(.ascending(\.age))
@@ -249,11 +249,11 @@ extension CoreStore {
*/ */
public static func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID? { public static func fetchObjectID<B: FetchChainableBuilderType>(_ 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 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. - 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { public static func fetchObjectIDs<D>(_ from: From<D>, _ 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 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. - 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { public static func fetchObjectIDs<D>(_ from: From<D>, _ 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<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID] { public static func fetchObjectIDs<B: FetchChainableBuilderType>(_ 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. 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<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? { public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ 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. 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<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? { public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ 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. 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<MyPersonEntity>() From<MyPersonEntity>()
.select(Int.self, .average(\.age)) .select(Int.self, .average(\.age))
.where(\.age > 18) .where(\.age > 18)
@@ -345,11 +345,11 @@ extension CoreStore {
*/ */
public static func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType { public static func queryValue<B: QueryChainableBuilderType>(_ 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. 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<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] { public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ 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. 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<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] { public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ 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. 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<MyPersonEntity>() From<MyPersonEntity>()
.select( .select(
NSDictionary.self, NSDictionary.self,
@@ -406,6 +406,6 @@ extension CoreStore {
*/ */
public static func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary { public static func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary {
return try Shared.defaultStack.queryAttributes(clauseChain) return try CoreStoreDefaults.dataStack.queryAttributes(clauseChain)
} }
} }

View File

@@ -33,90 +33,90 @@ import CoreData
extension CoreStore { 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 { 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] { 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] { 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? { 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? { 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() try CoreStore.addStorageAndWait()
``` ```
- returns: the local SQLite storage added to the `defaultStack` - returns: the local SQLite storage added to the `CoreStoreDefaults.dataStack`
*/ */
@discardableResult @discardableResult
public static func addStorageAndWait() throws -> SQLiteStore { 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")) try CoreStore.addStorageAndWait(InMemoryStore(configuration: "Config1"))
``` ```
- parameter storage: the `StorageInterface` - parameter storage: the `StorageInterface`
- throws: a `CoreStoreError` value indicating the failure - throws: a `CoreStoreError` value indicating the failure
- returns: the `StorageInterface` added to the `defaultStack` - returns: the `StorageInterface` added to the `CoreStoreDefaults.dataStack`
*/ */
@discardableResult @discardableResult
public static func addStorageAndWait<T: StorageInterface>(_ storage: T) throws -> T { public static func addStorageAndWait<T: StorageInterface>(_ 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")) try CoreStore.addStorageAndWait(SQLiteStore(configuration: "Config1"))
``` ```
- parameter storage: the local storage - parameter storage: the local storage
- throws: a `CoreStoreError` value indicating the failure - 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 @discardableResult
public static func addStorageAndWait<T: LocalStorage>(_ storage: T) throws -> T { public static func addStorageAndWait<T: LocalStorage>(_ 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( guard let storage = ICloudStore(
ubiquitousContentName: "MyAppCloudData", ubiquitousContentName: "MyAppCloudData",
@@ -138,6 +138,6 @@ extension CoreStore {
@discardableResult @discardableResult
public static func addStorageAndWait<T: CloudStorage>(_ storage: T) throws -> T { public static func addStorageAndWait<T: CloudStorage>(_ storage: T) throws -> T {
return try Shared.defaultStack.addStorageAndWait(storage) return try CoreStoreDefaults.dataStack.addStorageAndWait(storage)
} }
} }

View File

@@ -32,18 +32,18 @@ import Foundation
extension CoreStore { 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<T>`. 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<T>`. 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 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)`. - 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<T>(asynchronous task: @escaping (_ transaction: AsynchronousDataTransaction) throws -> T, completion: @escaping (AsynchronousDataTransaction.Result<T>) -> Void) { public static func perform<T>(asynchronous task: @escaping (_ transaction: AsynchronousDataTransaction) throws -> T, completion: @escaping (AsynchronousDataTransaction.Result<T>) -> 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 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`. - 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<T>(asynchronous task: @escaping (_ transaction: AsynchronousDataTransaction) throws -> T, success: @escaping (T) -> Void, failure: @escaping (CoreStoreError) -> Void) { public static func perform<T>(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 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`. - 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<T>(synchronous task: ((_ transaction: SynchronousDataTransaction) throws -> T), waitForAllObservers: Bool = true) throws -> T { public static func perform<T>(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. - 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. - returns: a `UnsafeDataTransaction` instance where creates, updates, and deletes can be made.
*/ */
public static func beginUnsafe(supportsUndo: Bool = false) -> UnsafeDataTransaction { 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() { public static func refreshAndMergeAllObjects() {
Shared.defaultStack.refreshAndMergeAllObjects() CoreStoreDefaults.dataStack.refreshAndMergeAllObjects()
} }
} }

View File

@@ -34,17 +34,17 @@ import CoreData
@available(*, deprecated, message: "Call methods directly from the DataStack instead") @available(*, deprecated, message: "Call methods directly from the DataStack instead")
public enum CoreStore { public enum CoreStore {
@available(*, unavailable, renamed: "Shared.logger") @available(*, unavailable, renamed: "CoreStoreDefaults.logger")
public static var logger: CoreStoreLogger { public static var logger: CoreStoreLogger {
get { return Shared.logger } get { return CoreStoreDefaults.logger }
set { Shared.logger = newValue } set { CoreStoreDefaults.logger = newValue }
} }
@available(*, unavailable, renamed: "Shared.defaultStack") @available(*, unavailable, renamed: "CoreStoreDefaults.dataStack")
public static var defaultStack: DataStack { public static var defaultStack: DataStack {
get { return Shared.defaultStack } get { return CoreStoreDefaults.dataStack }
set { Shared.defaultStack = newValue } set { CoreStoreDefaults.dataStack = newValue }
} }
} }

View File

@@ -1,5 +1,5 @@
// //
// Shared.swift // CoreStoreDefaults.swift
// CoreStore // CoreStore
// //
// Copyright © 2018 John Rommel Estropia // Copyright © 2018 John Rommel Estropia
@@ -26,19 +26,25 @@
import Foundation import Foundation
// MARK: - Shared // MARK: - CoreStoreDefaults
/** /**
Global utilities Global utilities
*/ */
public enum Shared { public enum CoreStoreDefaults {
/** /**
The `CoreStoreLogger` instance to be used. The default logger is an instance of a `DefaultLogger`. The `CoreStoreLogger` instance to be used. The default logger is an instance of a `DefaultLogger`.
*/ */
public static var logger: CoreStoreLogger = 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 { get {

View File

@@ -43,7 +43,7 @@ public enum LogLevel {
// MARK: - CoreStoreLogger // 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 { public protocol CoreStoreLogger {

View File

@@ -33,7 +33,7 @@ extension ValueContainer.Required {
/** /**
Creates a `Where` clause by comparing if a property is equal to a value Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.nickname == "John" })) let person = dataStack.fetchOne(From<Person>().where({ $0.nickname == "John" }))
``` ```
*/ */
public static func == (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> { public static func == (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> {
@@ -44,7 +44,7 @@ extension ValueContainer.Required {
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.nickname != "John" })) let person = dataStack.fetchOne(From<Person>().where({ $0.nickname != "John" }))
``` ```
*/ */
public static func != (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> { public static func != (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> {
@@ -55,7 +55,7 @@ extension ValueContainer.Required {
/** /**
Creates a `Where` clause by comparing if a property is less than a value Creates a `Where` clause by comparing if a property is less than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.age < 20 })) let person = dataStack.fetchOne(From<Person>().where({ $0.age < 20 }))
``` ```
*/ */
public static func < (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> { public static func < (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> {
@@ -66,7 +66,7 @@ extension ValueContainer.Required {
/** /**
Creates a `Where` clause by comparing if a property is greater than a value Creates a `Where` clause by comparing if a property is greater than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.age > 20 })) let person = dataStack.fetchOne(From<Person>().where({ $0.age > 20 }))
``` ```
*/ */
public static func > (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> { public static func > (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> {
@@ -77,7 +77,7 @@ extension ValueContainer.Required {
/** /**
Creates a `Where` clause by comparing if a property is less than or equal to a value Creates a `Where` clause by comparing if a property is less than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.age <= 20 })) let person = dataStack.fetchOne(From<Person>().where({ $0.age <= 20 }))
``` ```
*/ */
public static func <= (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> { public static func <= (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> {
@@ -88,7 +88,7 @@ extension ValueContainer.Required {
/** /**
Creates a `Where` clause by comparing if a property is greater than or equal to a value Creates a `Where` clause by comparing if a property is greater than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.age >= 20 })) let person = dataStack.fetchOne(From<Person>().where({ $0.age >= 20 }))
``` ```
*/ */
public static func >= (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> { public static func >= (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> {
@@ -99,7 +99,7 @@ extension ValueContainer.Required {
/** /**
Creates a `Where` clause by checking if a sequence contains the value of a property Creates a `Where` clause by checking if a sequence contains the value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where({ ["Pluto", "Snoopy", "Scooby"] ~= $0.nickname })) let dog = dataStack.fetchOne(From<Dog>().where({ ["Pluto", "Snoopy", "Scooby"] ~= $0.nickname }))
``` ```
*/ */
public static func ~= <S: Sequence>(_ sequence: S, _ attribute: ValueContainer<O>.Required<V>) -> Where<O> where S.Iterator.Element == V { public static func ~= <S: Sequence>(_ sequence: S, _ attribute: ValueContainer<O>.Required<V>) -> Where<O> 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 Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.nickname == "John" })) let person = dataStack.fetchOne(From<Person>().where({ $0.nickname == "John" }))
``` ```
*/ */
public static func == (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> { public static func == (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> {
@@ -127,7 +127,7 @@ extension ValueContainer.Optional {
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.nickname != "John" })) let person = dataStack.fetchOne(From<Person>().where({ $0.nickname != "John" }))
``` ```
*/ */
public static func != (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> { public static func != (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> {
@@ -138,7 +138,7 @@ extension ValueContainer.Optional {
/** /**
Creates a `Where` clause by comparing if a property is less than a value Creates a `Where` clause by comparing if a property is less than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.age < 20 })) let person = dataStack.fetchOne(From<Person>().where({ $0.age < 20 }))
``` ```
*/ */
public static func < (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> { public static func < (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> {
@@ -156,7 +156,7 @@ extension ValueContainer.Optional {
/** /**
Creates a `Where` clause by comparing if a property is greater than a value Creates a `Where` clause by comparing if a property is greater than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.age > 20 })) let person = dataStack.fetchOne(From<Person>().where({ $0.age > 20 }))
``` ```
*/ */
public static func > (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> { public static func > (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> {
@@ -174,7 +174,7 @@ extension ValueContainer.Optional {
/** /**
Creates a `Where` clause by comparing if a property is less than or equal to a value Creates a `Where` clause by comparing if a property is less than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.age <= 20 })) let person = dataStack.fetchOne(From<Person>().where({ $0.age <= 20 }))
``` ```
*/ */
public static func <= (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> { public static func <= (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> {
@@ -192,7 +192,7 @@ extension ValueContainer.Optional {
/** /**
Creates a `Where` clause by comparing if a property is greater than or equal to a value Creates a `Where` clause by comparing if a property is greater than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where({ $0.age >= 20 })) let person = dataStack.fetchOne(From<Person>().where({ $0.age >= 20 }))
``` ```
*/ */
public static func >= (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> { public static func >= (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where<O> {
@@ -210,7 +210,7 @@ extension ValueContainer.Optional {
/** /**
Creates a `Where` clause by checking if a sequence contains the value of a property Creates a `Where` clause by checking if a sequence contains the value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where({ ["Pluto", "Snoopy", "Scooby"] ~= $0.nickname })) let dog = dataStack.fetchOne(From<Dog>().where({ ["Pluto", "Snoopy", "Scooby"] ~= $0.nickname }))
``` ```
*/ */
public static func ~= <S: Sequence>(_ sequence: S, _ attribute: ValueContainer<O>.Optional<V>) -> Where<O> where S.Iterator.Element == V { public static func ~= <S: Sequence>(_ sequence: S, _ attribute: ValueContainer<O>.Optional<V>) -> Where<O> 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 Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where({ $0.master == me })) let dog = dataStack.fetchOne(From<Dog>().where({ $0.master == me }))
``` ```
*/ */
public static func == (_ relationship: RelationshipContainer<O>.ToOne<D>, _ object: D?) -> Where<O> { public static func == (_ relationship: RelationshipContainer<O>.ToOne<D>, _ object: D?) -> Where<O> {
@@ -238,7 +238,7 @@ extension RelationshipContainer.ToOne {
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where({ $0.master != me })) let dog = dataStack.fetchOne(From<Dog>().where({ $0.master != me }))
``` ```
*/ */
public static func != (_ relationship: RelationshipContainer<O>.ToOne<D>, _ object: D?) -> Where<O> { public static func != (_ relationship: RelationshipContainer<O>.ToOne<D>, _ object: D?) -> Where<O> {
@@ -249,7 +249,7 @@ extension RelationshipContainer.ToOne {
/** /**
Creates a `Where` clause by checking if a sequence contains the value of a property Creates a `Where` clause by checking if a sequence contains the value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where({ [john, joe, bob] ~= $0.master })) let dog = dataStack.fetchOne(From<Dog>().where({ [john, joe, bob] ~= $0.master }))
``` ```
*/ */
public static func ~= <S: Sequence>(_ sequence: S, _ relationship: RelationshipContainer<O>.ToOne<D>) -> Where<O> where S.Iterator.Element == D { public static func ~= <S: Sequence>(_ sequence: S, _ relationship: RelationshipContainer<O>.ToOne<D>) -> Where<O> where S.Iterator.Element == D {

View File

@@ -45,7 +45,7 @@ import Foundation
``` ```
`CoreStoreObject` entities for a model version should be added to `CoreStoreSchema` instance. `CoreStoreObject` entities for a model version should be added to `CoreStoreSchema` instance.
``` ```
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
CoreStoreSchema( CoreStoreSchema(
modelVersion: "V1", modelVersion: "V1",
entities: [ entities: [

View File

@@ -43,7 +43,7 @@ import Foundation
let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master }) let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master })
} }
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
CoreStoreSchema( CoreStoreSchema(
modelVersion: "V1", modelVersion: "V1",
entities: [ entities: [
@@ -76,7 +76,7 @@ public final class CoreStoreSchema: DynamicSchema {
let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master }) let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master })
} }
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
CoreStoreSchema( CoreStoreSchema(
modelVersion: "V1", modelVersion: "V1",
entities: [ entities: [
@@ -120,7 +120,7 @@ public final class CoreStoreSchema: DynamicSchema {
let name = Value.Required<String>("name", initial: "") let name = Value.Required<String>("name", initial: "")
} }
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
CoreStoreSchema( CoreStoreSchema(
modelVersion: "V1", modelVersion: "V1",
entityConfigurations: [ entityConfigurations: [

View File

@@ -63,7 +63,7 @@ public final class DataStack: Equatable {
/** /**
Convenience initializer for `DataStack` that creates a `SchemaHistory` from a list of `DynamicSchema` versions. Convenience initializer for `DataStack` that creates a `SchemaHistory` from a list of `DynamicSchema` versions.
``` ```
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
XcodeDataModelSchema(modelName: "MyModelV1"), XcodeDataModelSchema(modelName: "MyModelV1"),
CoreStoreSchema( CoreStoreSchema(
modelVersion: "MyModelV2", modelVersion: "MyModelV2",
@@ -92,7 +92,7 @@ public final class DataStack: Equatable {
/** /**
Initializes a `DataStack` from a `SchemaHistory` instance. Initializes a `DataStack` from a `SchemaHistory` instance.
``` ```
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
schemaHistory: SchemaHistory( schemaHistory: SchemaHistory(
XcodeDataModelSchema(modelName: "MyModelV1"), XcodeDataModelSchema(modelName: "MyModelV1"),
CoreStoreSchema( CoreStoreSchema(
@@ -472,7 +472,7 @@ public final class DataStack: Equatable {
enum Static { enum Static {
static var myDataKey: Void? static var myDataKey: Void?
} }
CoreStore.defaultStack.userInfo[&Static.myDataKey] = myObject CoreStoreDefaults.dataStack.userInfo[&Static.myDataKey] = myObject
``` ```
- Important: Do not use this method to store thread-sensitive data. - Important: Do not use this method to store thread-sensitive data.
*/ */

View File

@@ -1,5 +1,5 @@
// //
// DiffableDataSource.CollectionView.swift // DiffableDataSource.CollectionView-UIKit.swift
// CoreStore // CoreStore
// //
// Copyright © 2018 John Rommel Estropia // Copyright © 2018 John Rommel Estropia
@@ -23,7 +23,7 @@
// SOFTWARE. // SOFTWARE.
// //
#if canImport(UIKit) #if canImport(UIKit) && (os(iOS) || os(tvOS))
import UIKit import UIKit
import CoreData import CoreData
@@ -41,7 +41,7 @@ extension DiffableDataSource {
``` ```
self.dataSource = DiffableDataSource.CollectionView<Person>( self.dataSource = DiffableDataSource.CollectionView<Person>(
collectionView: self.collectionView, collectionView: self.collectionView,
dataStack: Shared.defaultStack, dataStack: CoreStoreDefaults.dataStack,
cellProvider: { (collectionView, indexPath, person) in cellProvider: { (collectionView, indexPath, person) in
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "PersonCell") as! PersonCell let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "PersonCell") as! PersonCell
cell.setPerson(person) cell.setPerson(person)
@@ -74,7 +74,7 @@ extension DiffableDataSource {
``` ```
self.dataSource = DiffableDataSource.CollectionView<Person>( self.dataSource = DiffableDataSource.CollectionView<Person>(
collectionView: self.collectionView, collectionView: self.collectionView,
dataStack: Shared.defaultStack, dataStack: CoreStoreDefaults.dataStack,
cellProvider: { (collectionView, indexPath, person) in cellProvider: { (collectionView, indexPath, person) in
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "PersonCell") as! PersonCell let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "PersonCell") as! PersonCell
cell.setPerson(person) cell.setPerson(person)
@@ -94,32 +94,10 @@ extension DiffableDataSource {
self.cellProvider = cellProvider self.cellProvider = cellProvider
self.supplementaryViewProvider = supplementaryViewProvider self.supplementaryViewProvider = supplementaryViewProvider
self.dataStack = dataStack self.dataStack = dataStack
self.dispatcher = Internals.DiffableDataUIDispatcher<O>(dataStack: dataStack)
super.init() super.init()
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) {
//
// self.rawDataSource = UITableViewDiffableDataSource<String, O.ObjectID>(
// tableView: tableView,
// cellProvider: { [weak self] (tableView, indexPath, objectID) -> UITableViewCell? in
//
// guard let self = self else {
//
// return nil
// }
// guard let object = self.dataStack.fetchExisting(objectID) as O? else {
//
// return nil
// }
// return self.cellProvider(tableView, indexPath, object)
// }
// )
// }
// else {
self.rawDataSource = Internals.DiffableDataUIDispatcher<O>(dataStack: dataStack)
// }
collectionView.dataSource = self collectionView.dataSource = self
} }
@@ -140,29 +118,18 @@ extension DiffableDataSource {
public func apply(_ snapshot: ListSnapshot<O>, animatingDifferences: Bool = true) { public func apply(_ snapshot: ListSnapshot<O>, animatingDifferences: Bool = true) {
let diffableSnapshot = snapshot.diffableSnapshot let diffableSnapshot = snapshot.diffableSnapshot
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { self.dispatcher.apply(
// diffableSnapshot as! Internals.DiffableDataSourceSnapshot,
// self.modernDataSource.apply( view: self.collectionView,
// diffableSnapshot as! NSDiffableDataSourceSnapshot<String, NSManagedObjectID>, animatingDifferences: animatingDifferences,
// animatingDifferences: animatingDifferences, performUpdates: { collectionView, changeset, setSections in
// completion: nil
// )
// }
// else {
self.legacyDataSource.apply( collectionView.reload(
diffableSnapshot as! Internals.DiffableDataSourceSnapshot, using: changeset,
view: self.collectionView, setData: setSections
animatingDifferences: animatingDifferences, )
performUpdates: { collectionView, changeset, setSections in }
)
collectionView.reload(
using: changeset,
setData: setSections
)
}
)
// }
} }
/** /**
@@ -174,14 +141,7 @@ extension DiffableDataSource {
@nonobjc @nonobjc
public func itemID(for indexPath: IndexPath) -> O.ObjectID? { public func itemID(for indexPath: IndexPath) -> O.ObjectID? {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { return self.dispatcher.itemIdentifier(for: indexPath)
//
// return self.modernDataSource.itemIdentifier(for: indexPath)
// }
// else {
return self.legacyDataSource.itemIdentifier(for: indexPath)
// }
} }
/** /**
@@ -193,14 +153,7 @@ extension DiffableDataSource {
@nonobjc @nonobjc
public func indexPath(for itemID: O.ObjectID) -> IndexPath? { public func indexPath(for itemID: O.ObjectID) -> IndexPath? {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { return self.dispatcher.indexPath(for: itemID)
//
// return self.modernDataSource.indexPath(for: itemIdentifier)
// }
// else {
return self.legacyDataSource.indexPath(for: itemID)
// }
} }
@@ -209,52 +162,31 @@ extension DiffableDataSource {
@objc @objc
public dynamic func numberOfSections(in collectionView: UICollectionView) -> Int { public dynamic func numberOfSections(in collectionView: UICollectionView) -> Int {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { return self.dispatcher.numberOfSections()
//
// return self.modernDataSource.numberOfSections(in: tableView)
// }
// else {
return self.legacyDataSource.numberOfSections()
// }
} }
@objc @objc
public dynamic func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { public dynamic func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { return self.dispatcher.numberOfItems(inSection: section)
//
// return self.modernDataSource.tableView(tableView, numberOfRowsInSection: section)
// }
// else {
return self.legacyDataSource.numberOfItems(inSection: section)
// }
} }
@objc @objc
open dynamic func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { open dynamic func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { guard let objectID = self.dispatcher.itemIdentifier(for: indexPath) else {
//
// return self.modernDataSource.tableView(tableView, cellForRowAt: indexPath)
// }
// else {
guard let objectID = self.legacyDataSource.itemIdentifier(for: indexPath) else { Internals.abort("Object at \(Internals.typeName(IndexPath.self)) \(indexPath) already removed from list")
}
guard let object = self.dataStack.fetchExisting(objectID) as O? else {
Internals.abort("Object at \(Internals.typeName(IndexPath.self)) \(indexPath) already removed from list") Internals.abort("Object at \(Internals.typeName(IndexPath.self)) \(indexPath) has been deleted")
} }
guard let object = self.dataStack.fetchExisting(objectID) as O? else { guard let cell = self.cellProvider(collectionView, indexPath, object) else {
Internals.abort("Object at \(Internals.typeName(IndexPath.self)) \(indexPath) has been deleted") Internals.abort("\(Internals.typeName(UICollectionViewDataSource.self)) returned a `nil` cell for \(Internals.typeName(IndexPath.self)) \(indexPath)")
} }
guard let cell = self.cellProvider(collectionView, indexPath, object) else { return cell
Internals.abort("\(Internals.typeName(UICollectionViewDataSource.self)) returned a `nil` cell for \(Internals.typeName(IndexPath.self)) \(indexPath)")
}
return cell
// }
} }
@objc @objc
@@ -275,18 +207,7 @@ extension DiffableDataSource {
private let dataStack: DataStack private let dataStack: DataStack
private let cellProvider: (UICollectionView, IndexPath, O) -> UICollectionViewCell? private let cellProvider: (UICollectionView, IndexPath, O) -> UICollectionViewCell?
private let supplementaryViewProvider: (UICollectionView, String, IndexPath) -> UICollectionReusableView? private let supplementaryViewProvider: (UICollectionView, String, IndexPath) -> UICollectionReusableView?
private var rawDataSource: Any! private let dispatcher: Internals.DiffableDataUIDispatcher<O>
// @available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
// private var modernDataSource: UITableViewDiffableDataSource<String, O.ObjectID> {
//
// return self.rawDataSource as! UITableViewDiffableDataSource<String, O.ObjectID>
// }
private var legacyDataSource: Internals.DiffableDataUIDispatcher<O> {
return self.rawDataSource as! Internals.DiffableDataUIDispatcher<O>
}
} }
} }
@@ -340,19 +261,28 @@ extension UICollectionView {
} }
if !changeset.elementDeleted.isEmpty { if !changeset.elementDeleted.isEmpty {
self.deleteItems(at: changeset.elementDeleted.map { IndexPath(row: $0.element, section: $0.section) }) self.deleteItems(
at: changeset.elementDeleted.map { IndexPath(item: $0.element, section: $0.section) }
)
} }
if !changeset.elementInserted.isEmpty { if !changeset.elementInserted.isEmpty {
self.insertItems(at: changeset.elementInserted.map { IndexPath(row: $0.element, section: $0.section) }) self.insertItems(
at: changeset.elementInserted.map { IndexPath(item: $0.element, section: $0.section) }
)
} }
if !changeset.elementUpdated.isEmpty { if !changeset.elementUpdated.isEmpty {
self.reloadItems(at: changeset.elementUpdated.map { IndexPath(row: $0.element, section: $0.section) }) self.reloadItems(
at: changeset.elementUpdated.map { IndexPath(item: $0.element, section: $0.section) }
)
} }
for (source, target) in changeset.elementMoved { for (source, target) in changeset.elementMoved {
self.moveItem(at: IndexPath(row: source.element, section: source.section), to: IndexPath(row: target.element, section: target.section)) self.moveItem(
at: IndexPath(item: source.element, section: source.section),
to: IndexPath(item: target.element, section: target.section)
)
} }
}, },
completion: nil completion: nil

View File

@@ -1,5 +1,5 @@
// //
// DiffableDataSource.TableView.swift // DiffableDataSource.TableView-UIKit.swift
// CoreStore // CoreStore
// //
// Copyright © 2018 John Rommel Estropia // Copyright © 2018 John Rommel Estropia
@@ -23,7 +23,7 @@
// SOFTWARE. // SOFTWARE.
// //
#if canImport(UIKit) #if canImport(UIKit) && (os(iOS) || os(tvOS))
import UIKit import UIKit
import CoreData import CoreData
@@ -41,7 +41,7 @@ extension DiffableDataSource {
``` ```
self.dataSource = DiffableDataSource.TableView<Person>( self.dataSource = DiffableDataSource.TableView<Person>(
tableView: self.tableView, tableView: self.tableView,
dataStack: Shared.defaultStack, dataStack: CoreStoreDefaults.dataStack,
cellProvider: { (tableView, indexPath, person) in cellProvider: { (tableView, indexPath, person) in
let cell = tableView.dequeueReusableCell(withIdentifier: "PersonCell") as! PersonCell let cell = tableView.dequeueReusableCell(withIdentifier: "PersonCell") as! PersonCell
cell.setPerson(person) cell.setPerson(person)
@@ -83,7 +83,7 @@ extension DiffableDataSource {
``` ```
self.dataSource = DiffableDataSource.TableView<Person>( self.dataSource = DiffableDataSource.TableView<Person>(
tableView: self.tableView, tableView: self.tableView,
dataStack: Shared.defaultStack, dataStack: CoreStoreDefaults.dataStack,
cellProvider: { (tableView, indexPath, person) in cellProvider: { (tableView, indexPath, person) in
let cell = tableView.dequeueReusableCell(withIdentifier: "PersonCell") as! PersonCell let cell = tableView.dequeueReusableCell(withIdentifier: "PersonCell") as! PersonCell
cell.setPerson(person) cell.setPerson(person)
@@ -101,31 +101,9 @@ extension DiffableDataSource {
self.tableView = tableView self.tableView = tableView
self.cellProvider = cellProvider self.cellProvider = cellProvider
self.dataStack = dataStack self.dataStack = dataStack
self.dispatcher = Internals.DiffableDataUIDispatcher<O>(dataStack: dataStack)
super.init() super.init()
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) {
//
// self.rawDataSource = UITableViewDiffableDataSource<String, O.ObjectID>(
// tableView: tableView,
// cellProvider: { [weak self] (tableView, indexPath, objectID) -> UITableViewCell? in
//
// guard let self = self else {
//
// return nil
// }
// guard let object = self.dataStack.fetchExisting(objectID) as O? else {
//
// return nil
// }
// return self.cellProvider(tableView, indexPath, object)
// }
// )
// }
// else {
self.rawDataSource = Internals.DiffableDataUIDispatcher<O>(dataStack: dataStack)
// }
tableView.dataSource = self tableView.dataSource = self
} }
@@ -159,7 +137,7 @@ extension DiffableDataSource {
// } // }
// else { // else {
self.legacyDataSource.apply( self.dispatcher.apply(
diffableSnapshot as! Internals.DiffableDataSourceSnapshot, diffableSnapshot as! Internals.DiffableDataSourceSnapshot,
view: self.tableView, view: self.tableView,
animatingDifferences: animatingDifferences, animatingDifferences: animatingDifferences,
@@ -184,14 +162,7 @@ extension DiffableDataSource {
@nonobjc @nonobjc
public func itemID(for indexPath: IndexPath) -> O.ObjectID? { public func itemID(for indexPath: IndexPath) -> O.ObjectID? {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { return self.dispatcher.itemIdentifier(for: indexPath)
//
// return self.modernDataSource.itemIdentifier(for: indexPath)
// }
// else {
return self.legacyDataSource.itemIdentifier(for: indexPath)
// }
} }
/** /**
@@ -203,14 +174,7 @@ extension DiffableDataSource {
@nonobjc @nonobjc
public func indexPath(for itemID: O.ObjectID) -> IndexPath? { public func indexPath(for itemID: O.ObjectID) -> IndexPath? {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { return self.dispatcher.indexPath(for: itemID)
//
// return self.modernDataSource.indexPath(for: itemIdentifier)
// }
// else {
return self.legacyDataSource.indexPath(for: itemID)
// }
} }
@@ -219,78 +183,43 @@ extension DiffableDataSource {
@objc @objc
public dynamic func numberOfSections(in tableView: UITableView) -> Int { public dynamic func numberOfSections(in tableView: UITableView) -> Int {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { return self.dispatcher.numberOfSections()
//
// return self.modernDataSource.numberOfSections(in: tableView)
// }
// else {
return self.legacyDataSource.numberOfSections()
// }
} }
@objc @objc
public dynamic func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { public dynamic func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { return self.dispatcher.numberOfItems(inSection: section)
//
// return self.modernDataSource.tableView(tableView, numberOfRowsInSection: section)
// }
// else {
return self.legacyDataSource.numberOfItems(inSection: section)
// }
} }
@objc @objc
open dynamic func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { open dynamic func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { return self.dispatcher.sectionIdentifier(inSection: section)
//
// return self.modernDataSource.snapshot().sectionIdentifiers[section]
// }
// else {
return self.legacyDataSource.sectionIdentifier(inSection: section)
// }
} }
@objc @objc
open dynamic func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { open dynamic func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { return nil
//
// return self.modernDataSource.tableView(tableView, titleForFooterInSection: section)
// }
// else {
return nil
// }
} }
@objc @objc
open dynamic func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { open dynamic func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) { guard let objectID = self.dispatcher.itemIdentifier(for: indexPath) else {
//
// return self.modernDataSource.tableView(tableView, cellForRowAt: indexPath) Internals.abort("Object at \(Internals.typeName(IndexPath.self)) \(indexPath) already removed from list")
// } }
// else { guard let object = self.dataStack.fetchExisting(objectID) as O? else {
guard let objectID = self.legacyDataSource.itemIdentifier(for: indexPath) else { Internals.abort("Object at \(Internals.typeName(IndexPath.self)) \(indexPath) has been deleted")
}
Internals.abort("Object at \(Internals.typeName(IndexPath.self)) \(indexPath) already removed from list") guard let cell = self.cellProvider(tableView, indexPath, object) else {
}
guard let object = self.dataStack.fetchExisting(objectID) as O? else { Internals.abort("\(Internals.typeName(UITableViewDataSource.self)) returned a `nil` cell for \(Internals.typeName(IndexPath.self)) \(indexPath)")
}
Internals.abort("Object at \(Internals.typeName(IndexPath.self)) \(indexPath) has been deleted") return cell
}
guard let cell = self.cellProvider(tableView, indexPath, object) else {
Internals.abort("\(Internals.typeName(UITableViewDataSource.self)) returned a `nil` cell for \(Internals.typeName(IndexPath.self)) \(indexPath)")
}
return cell
// }
} }
@objc @objc
@@ -321,19 +250,7 @@ extension DiffableDataSource {
private let cellProvider: (UITableView, IndexPath, O) -> UITableViewCell? private let cellProvider: (UITableView, IndexPath, O) -> UITableViewCell?
@nonobjc @nonobjc
private var rawDataSource: Any! private let dispatcher: Internals.DiffableDataUIDispatcher<O>
// @available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
// private var modernDataSource: UITableViewDiffableDataSource<String, O.ObjectID> {
//
// return self.rawDataSource as! UITableViewDiffableDataSource<String, O.ObjectID>
// }
@nonobjc
private var legacyDataSource: Internals.DiffableDataUIDispatcher<O> {
return self.rawDataSource as! Internals.DiffableDataUIDispatcher<O>
}
} }
} }

View File

@@ -23,6 +23,7 @@
// SOFTWARE. // SOFTWARE.
// //
#if os(iOS) || os(tvOS) || os(macOS)
// MARK: - DiffableDataSource // MARK: - DiffableDataSource
@@ -30,3 +31,5 @@
Namespace for diffable data source types. See `DiffableDataSource.TableView` and `DiffableDataSource.CollectionView` for actual implementations Namespace for diffable data source types. See `DiffableDataSource.TableView` and `DiffableDataSource.CollectionView` for actual implementations
*/ */
public enum DiffableDataSource {} public enum DiffableDataSource {}
#endif

View File

@@ -44,7 +44,7 @@ import ObjectiveC
let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master }) let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master })
} }
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
CoreStoreSchema( CoreStoreSchema(
modelVersion: "V1", modelVersion: "V1",
entities: [ entities: [

View File

@@ -23,9 +23,12 @@
// SOFTWARE. // SOFTWARE.
// //
#if canImport(SwiftUI) #if canImport(SwiftUI) && canImport(Combine)
import SwiftUI import SwiftUI
import Combine
import CoreData
// MARK: - EnvironmentValues // MARK: - EnvironmentValues
@@ -64,7 +67,7 @@ extension EnvironmentValues {
fileprivate static var defaultValue: DataStack { fileprivate static var defaultValue: DataStack {
return Shared.defaultStack return CoreStoreDefaults.dataStack
} }
} }
} }

View File

@@ -37,7 +37,7 @@ import CoreData
// ... // ...
} }
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let json: NSDictionary = // ... let json: NSDictionary = // ...
let person = try transaction.importObject( let person = try transaction.importObject(

View File

@@ -38,7 +38,7 @@ import CoreData
// ... // ...
} }
CoreStore.perform( dataStack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
let json: NSDictionary = // ... let json: NSDictionary = // ...
let person = try transaction.importUniqueObject( let person = try transaction.importUniqueObject(

View File

@@ -568,10 +568,4 @@ extension Internals {
} }
// MARK: - NSDiffableDataSourceSnapshot: DiffableDataSourceSnapshotProtocol
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 15.0, *)
extension NSDiffableDataSourceSnapshot: DiffableDataSourceSnapshotProtocol where SectionIdentifierType == String, ItemIdentifierType == NSManagedObjectID {}
#endif #endif

View File

@@ -32,7 +32,7 @@ import Foundation
/** /**
Creates a `Where` clause by comparing if a property is equal to a value Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.nickname == "John")) let person = dataStack.fetchOne(From<Person>().where(\.nickname == "John"))
``` ```
*/ */
public func == <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> { public func == <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> {
@@ -43,7 +43,7 @@ public func == <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ key
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.nickname != "John")) let person = dataStack.fetchOne(From<Person>().where(\.nickname != "John"))
``` ```
*/ */
public func != <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> { public func != <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> {
@@ -54,7 +54,7 @@ public func != <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ key
/** /**
Creates a `Where` clause by checking if a sequence contains the value of a property Creates a `Where` clause by checking if a sequence contains the value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(["Pluto", "Snoopy", "Scooby"] ~= \.nickname)) let dog = dataStack.fetchOne(From<Dog>().where(["Pluto", "Snoopy", "Scooby"] ~= \.nickname))
``` ```
*/ */
public func ~= <O: NSManagedObject, V: QueryableAttributeType & Equatable, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, V>) -> Where<O> where S.Iterator.Element == V { public func ~= <O: NSManagedObject, V: QueryableAttributeType & Equatable, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, V>) -> Where<O> where S.Iterator.Element == V {
@@ -68,7 +68,7 @@ public func ~= <O: NSManagedObject, V: QueryableAttributeType & Equatable, S: Se
/** /**
Creates a `Where` clause by comparing if a property is equal to a value Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.nickname == "John")) let person = dataStack.fetchOne(From<Person>().where(\.nickname == "John"))
``` ```
*/ */
public func == <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> { public func == <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> {
@@ -79,7 +79,7 @@ public func == <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ key
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.nickname != "John")) let person = dataStack.fetchOne(From<Person>().where(\.nickname != "John"))
``` ```
*/ */
public func != <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> { public func != <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> {
@@ -90,7 +90,7 @@ public func != <O: NSManagedObject, V: QueryableAttributeType & Equatable>(_ key
/** /**
Creates a `Where` clause by checking if a sequence contains the value of a property Creates a `Where` clause by checking if a sequence contains the value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(["Pluto", "Snoopy", "Scooby"] ~= \.nickname)) let dog = dataStack.fetchOne(From<Dog>().where(["Pluto", "Snoopy", "Scooby"] ~= \.nickname))
``` ```
*/ */
public func ~= <O: NSManagedObject, V: QueryableAttributeType & Equatable, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, Optional<V>>) -> Where<O> where S.Iterator.Element == V { public func ~= <O: NSManagedObject, V: QueryableAttributeType & Equatable, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, Optional<V>>) -> Where<O> where S.Iterator.Element == V {
@@ -104,7 +104,7 @@ public func ~= <O: NSManagedObject, V: QueryableAttributeType & Equatable, S: Se
/** /**
Creates a `Where` clause by comparing if a property is less than a value Creates a `Where` clause by comparing if a property is less than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age < 20)) let person = dataStack.fetchOne(From<Person>().where(\.age < 20))
``` ```
*/ */
public func < <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> { public func < <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> {
@@ -115,7 +115,7 @@ public func < <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ key
/** /**
Creates a `Where` clause by comparing if a property is greater than a value Creates a `Where` clause by comparing if a property is greater than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age > 20)) let person = dataStack.fetchOne(From<Person>().where(\.age > 20))
``` ```
*/ */
public func > <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> { public func > <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> {
@@ -126,7 +126,7 @@ public func > <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ key
/** /**
Creates a `Where` clause by comparing if a property is less than or equal to a value Creates a `Where` clause by comparing if a property is less than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age <= 20)) let person = dataStack.fetchOne(From<Person>().where(\.age <= 20))
``` ```
*/ */
public func <= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> { public func <= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> {
@@ -137,7 +137,7 @@ public func <= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ ke
/** /**
Creates a `Where` clause by comparing if a property is greater than or equal to a value Creates a `Where` clause by comparing if a property is greater than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age >= 20)) let person = dataStack.fetchOne(From<Person>().where(\.age >= 20))
``` ```
*/ */
public func >= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> { public func >= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> {
@@ -151,7 +151,7 @@ public func >= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ ke
/** /**
Creates a `Where` clause by comparing if a property is less than a value Creates a `Where` clause by comparing if a property is less than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age < 20)) let person = dataStack.fetchOne(From<Person>().where(\.age < 20))
``` ```
*/ */
public func < <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> { public func < <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> {
@@ -169,7 +169,7 @@ public func < <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ key
/** /**
Creates a `Where` clause by comparing if a property is greater than a value Creates a `Where` clause by comparing if a property is greater than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age > 20)) let person = dataStack.fetchOne(From<Person>().where(\.age > 20))
``` ```
*/ */
public func > <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> { public func > <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> {
@@ -187,7 +187,7 @@ public func > <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ key
/** /**
Creates a `Where` clause by comparing if a property is less than or equal to a value Creates a `Where` clause by comparing if a property is less than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age <= 20)) let person = dataStack.fetchOne(From<Person>().where(\.age <= 20))
``` ```
*/ */
public func <= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> { public func <= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> {
@@ -205,7 +205,7 @@ public func <= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ ke
/** /**
Creates a `Where` clause by comparing if a property is greater than or equal to a value Creates a `Where` clause by comparing if a property is greater than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age >= 20)) let person = dataStack.fetchOne(From<Person>().where(\.age >= 20))
``` ```
*/ */
public func >= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> { public func >= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, Optional<V>>, _ value: V?) -> Where<O> {
@@ -226,7 +226,7 @@ public func >= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ ke
/** /**
Creates a `Where` clause by comparing if a property is equal to a value Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master == john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master == john))
``` ```
*/ */
public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>, _ object: D) -> Where<O> { public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>, _ object: D) -> Where<O> {
@@ -237,7 +237,7 @@ public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master != john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master != john))
``` ```
*/ */
public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>, _ object: D) -> Where<O> { public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>, _ object: D) -> Where<O> {
@@ -248,7 +248,7 @@ public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>
/** /**
Creates a `Where` clause by checking if a sequence contains a value of a property Creates a `Where` clause by checking if a sequence contains a value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where([john, bob, joe] ~= \.master)) let dog = dataStack.fetchOne(From<Dog>().where([john, bob, joe] ~= \.master))
``` ```
*/ */
public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, D>) -> Where<O> where S.Iterator.Element == D { public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, D>) -> Where<O> where S.Iterator.Element == D {
@@ -259,7 +259,7 @@ public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence:
/** /**
Creates a `Where` clause by comparing if a property is equal to a value Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master == john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master == john))
``` ```
*/ */
public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>, _ objectID: NSManagedObjectID) -> Where<O> { public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>, _ objectID: NSManagedObjectID) -> Where<O> {
@@ -270,7 +270,7 @@ public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master != john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master != john))
``` ```
*/ */
public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>, _ objectID: NSManagedObjectID) -> Where<O> { public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>, _ objectID: NSManagedObjectID) -> Where<O> {
@@ -281,7 +281,7 @@ public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, D>
/** /**
Creates a `Where` clause by checking if a sequence contains a value of a property Creates a `Where` clause by checking if a sequence contains a value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where([john, bob, joe] ~= \.master)) let dog = dataStack.fetchOne(From<Dog>().where([john, bob, joe] ~= \.master))
``` ```
*/ */
public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, D>) -> Where<O> where S.Iterator.Element == NSManagedObjectID { public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, D>) -> Where<O> where S.Iterator.Element == NSManagedObjectID {
@@ -295,7 +295,7 @@ public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence:
/** /**
Creates a `Where` clause by comparing if a property is equal to a value Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master == john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master == john))
``` ```
*/ */
public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Optional<D>>, _ object: D?) -> Where<O> { public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Optional<D>>, _ object: D?) -> Where<O> {
@@ -306,7 +306,7 @@ public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Op
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master != john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master != john))
``` ```
*/ */
public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Optional<D>>, _ object: D?) -> Where<O> { public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Optional<D>>, _ object: D?) -> Where<O> {
@@ -317,7 +317,7 @@ public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Op
/** /**
Creates a `Where` clause by checking if a sequence contains a value of a property Creates a `Where` clause by checking if a sequence contains a value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where([john, bob, joe] ~= \.master)) let dog = dataStack.fetchOne(From<Dog>().where([john, bob, joe] ~= \.master))
``` ```
*/ */
public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, Optional<D>>) -> Where<O> where S.Iterator.Element == D { public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, Optional<D>>) -> Where<O> where S.Iterator.Element == D {
@@ -328,7 +328,7 @@ public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence:
/** /**
Creates a `Where` clause by comparing if a property is equal to a value Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master == john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master == john))
``` ```
*/ */
public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Optional<D>>, _ objectID: NSManagedObjectID) -> Where<O> { public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Optional<D>>, _ objectID: NSManagedObjectID) -> Where<O> {
@@ -339,7 +339,7 @@ public func == <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Op
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master != john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master != john))
``` ```
*/ */
public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Optional<D>>, _ objectID: NSManagedObjectID) -> Where<O> { public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Optional<D>>, _ objectID: NSManagedObjectID) -> Where<O> {
@@ -350,7 +350,7 @@ public func != <O: NSManagedObject, D: NSManagedObject>(_ keyPath: KeyPath<O, Op
/** /**
Creates a `Where` clause by checking if a sequence contains a value of a property Creates a `Where` clause by checking if a sequence contains a value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where([john, bob, joe] ~= \.master)) let dog = dataStack.fetchOne(From<Dog>().where([john, bob, joe] ~= \.master))
``` ```
*/ */
public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, Optional<D>>) -> Where<O> where S.Iterator.Element == NSManagedObjectID { public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, Optional<D>>) -> Where<O> where S.Iterator.Element == NSManagedObjectID {
@@ -364,7 +364,7 @@ public func ~= <O: NSManagedObject, D: NSManagedObject, S: Sequence>(_ sequence:
/** /**
Creates a `Where` clause by comparing if a property is equal to a value Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.nickname == "John")) let person = dataStack.fetchOne(From<Person>().where(\.nickname == "John"))
``` ```
*/ */
public func == <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> { public func == <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> {
@@ -375,7 +375,7 @@ public func == <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ va
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.nickname != "John")) let person = dataStack.fetchOne(From<Person>().where(\.nickname != "John"))
``` ```
*/ */
public func != <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> { public func != <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> {
@@ -386,7 +386,7 @@ public func != <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ va
/** /**
Creates a `Where` clause by checking if a sequence contains the value of a property Creates a `Where` clause by checking if a sequence contains the value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(["Pluto", "Snoopy", "Scooby"] ~= \.nickname)) let dog = dataStack.fetchOne(From<Dog>().where(["Pluto", "Snoopy", "Scooby"] ~= \.nickname))
``` ```
*/ */
public func ~= <O, V, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>) -> Where<O> where S.Iterator.Element == V { public func ~= <O, V, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>) -> Where<O> where S.Iterator.Element == V {
@@ -400,7 +400,7 @@ public func ~= <O, V, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, ValueCon
/** /**
Creates a `Where` clause by comparing if a property is equal to a value Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.nickname == "John")) let person = dataStack.fetchOne(From<Person>().where(\.nickname == "John"))
``` ```
*/ */
public func == <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> { public func == <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> {
@@ -411,7 +411,7 @@ public func == <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ va
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.nickname != "John")) let person = dataStack.fetchOne(From<Person>().where(\.nickname != "John"))
``` ```
*/ */
public func != <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> { public func != <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> {
@@ -422,7 +422,7 @@ public func != <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ va
/** /**
Creates a `Where` clause by checking if a sequence contains the value of a property Creates a `Where` clause by checking if a sequence contains the value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(["Pluto", "Snoopy", "Scooby"] ~= \.nickname)) let dog = dataStack.fetchOne(From<Dog>().where(["Pluto", "Snoopy", "Scooby"] ~= \.nickname))
``` ```
*/ */
public func ~= <O, V, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>) -> Where<O> where S.Iterator.Element == V { public func ~= <O, V, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>) -> Where<O> where S.Iterator.Element == V {
@@ -436,7 +436,7 @@ public func ~= <O, V, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, ValueCon
/** /**
Creates a `Where` clause by comparing if a property is less than a value Creates a `Where` clause by comparing if a property is less than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age < 20)) let person = dataStack.fetchOne(From<Person>().where(\.age < 20))
``` ```
*/ */
public func < <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> { public func < <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> {
@@ -447,7 +447,7 @@ public func < <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Require
/** /**
Creates a `Where` clause by comparing if a property is greater than a value Creates a `Where` clause by comparing if a property is greater than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age > 20)) let person = dataStack.fetchOne(From<Person>().where(\.age > 20))
``` ```
*/ */
public func > <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> { public func > <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> {
@@ -458,7 +458,7 @@ public func > <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Require
/** /**
Creates a `Where` clause by comparing if a property is less than or equal to a value Creates a `Where` clause by comparing if a property is less than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age <= 20)) let person = dataStack.fetchOne(From<Person>().where(\.age <= 20))
``` ```
*/ */
public func <= <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> { public func <= <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> {
@@ -469,7 +469,7 @@ public func <= <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Requir
/** /**
Creates a `Where` clause by comparing if a property is greater than or equal to a value Creates a `Where` clause by comparing if a property is greater than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age >= 20)) let person = dataStack.fetchOne(From<Person>().where(\.age >= 20))
``` ```
*/ */
public func >= <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> { public func >= <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> {
@@ -483,7 +483,7 @@ public func >= <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Requir
/** /**
Creates a `Where` clause by comparing if a property is less than a value Creates a `Where` clause by comparing if a property is less than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age < 20)) let person = dataStack.fetchOne(From<Person>().where(\.age < 20))
``` ```
*/ */
public func < <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> { public func < <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> {
@@ -501,7 +501,7 @@ public func < <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ val
/** /**
Creates a `Where` clause by comparing if a property is greater than a value Creates a `Where` clause by comparing if a property is greater than a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age > 20)) let person = dataStack.fetchOne(From<Person>().where(\.age > 20))
``` ```
*/ */
public func > <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> { public func > <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> {
@@ -519,7 +519,7 @@ public func > <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ val
/** /**
Creates a `Where` clause by comparing if a property is less than or equal to a value Creates a `Where` clause by comparing if a property is less than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age <= 20)) let person = dataStack.fetchOne(From<Person>().where(\.age <= 20))
``` ```
*/ */
public func <= <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> { public func <= <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> {
@@ -537,7 +537,7 @@ public func <= <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ va
/** /**
Creates a `Where` clause by comparing if a property is greater than or equal to a value Creates a `Where` clause by comparing if a property is greater than or equal to a value
``` ```
let person = CoreStore.fetchOne(From<Person>().where(\.age >= 20)) let person = dataStack.fetchOne(From<Person>().where(\.age >= 20))
``` ```
*/ */
public func >= <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> { public func >= <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ value: V?) -> Where<O> {
@@ -558,7 +558,7 @@ public func >= <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ va
/** /**
Creates a `Where` clause by comparing if a property is equal to a value Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master == john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master == john))
``` ```
*/ */
public func == <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, _ object: D) -> Where<O> { public func == <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, _ object: D) -> Where<O> {
@@ -569,7 +569,7 @@ public func == <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>,
/** /**
Creates a `Where` clause by comparing if a property is equal to a value Creates a `Where` clause by comparing if a property is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master == john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master == john))
``` ```
*/ */
public func == <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, _ object: D?) -> Where<O> { public func == <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, _ object: D?) -> Where<O> {
@@ -580,7 +580,7 @@ public func == <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>,
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master != john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master != john))
``` ```
*/ */
public func != <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, _ object: D) -> Where<O> { public func != <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, _ object: D) -> Where<O> {
@@ -591,7 +591,7 @@ public func != <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>,
/** /**
Creates a `Where` clause by comparing if a property is not equal to a value Creates a `Where` clause by comparing if a property is not equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(\.master != john)) let dog = dataStack.fetchOne(From<Dog>().where(\.master != john))
``` ```
*/ */
public func != <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, _ object: D?) -> Where<O> { public func != <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, _ object: D?) -> Where<O> {
@@ -602,7 +602,7 @@ public func != <O, D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>,
/** /**
Creates a `Where` clause by checking if a sequence contains a value of a property Creates a `Where` clause by checking if a sequence contains a value of a property
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where([john, bob, joe] ~= \.master)) let dog = dataStack.fetchOne(From<Dog>().where([john, bob, joe] ~= \.master))
``` ```
*/ */
public func ~= <O, D, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>) -> Where<O> where S.Iterator.Element == D { public func ~= <O, D, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>) -> Where<O> where S.Iterator.Element == D {

View File

@@ -32,7 +32,7 @@ import CoreData
/** /**
The `ListMonitor` monitors changes to a list of `DynamicObject` instances. Observers that implement the `ListObserver` protocol may then register themselves to the `ListMonitor`'s `addObserver(_:)` method: The `ListMonitor` monitors changes to a list of `DynamicObject` instances. Observers that implement the `ListObserver` protocol may then register themselves to the `ListMonitor`'s `addObserver(_:)` method:
``` ```
let monitor = CoreStore.monitorList( let monitor = dataStack.monitorList(
From<Person>(), From<Person>(),
Where("title", isEqualTo: "Engineer"), Where("title", isEqualTo: "Engineer"),
OrderBy(.ascending("lastName")) OrderBy(.ascending("lastName"))
@@ -50,7 +50,7 @@ import CoreData
Creating a sectioned-list is also possible with the `monitorSectionedList(...)` method: Creating a sectioned-list is also possible with the `monitorSectionedList(...)` method:
``` ```
let monitor = CoreStore.monitorSectionedList( let monitor = dataStack.monitorSectionedList(
From<Person>(), From<Person>(),
SectionBy("age") { "Age \($0)" }, SectionBy("age") { "Age \($0)" },
Where("title", isEqualTo: "Engineer"), Where("title", isEqualTo: "Engineer"),

View File

@@ -32,7 +32,7 @@ import CoreData
/** /**
Implement the `ListObserver` protocol to observe changes to a list of `NSManagedObject`s. `ListObserver`s may register themselves to a `ListMonitor`'s `addObserver(_:)` method: Implement the `ListObserver` protocol to observe changes to a list of `NSManagedObject`s. `ListObserver`s may register themselves to a `ListMonitor`'s `addObserver(_:)` method:
``` ```
let monitor = CoreStore.monitorList( let monitor = dataStack.monitorList(
From<Person>(), From<Person>(),
OrderBy(.ascending("lastName")) OrderBy(.ascending("lastName"))
) )
@@ -96,7 +96,7 @@ extension ListObserver {
/** /**
Implement the `ListObjectObserver` protocol to observe detailed changes to a list's object. `ListObjectObserver`s may register themselves to a `ListMonitor`'s `addObserver(_:)` method: Implement the `ListObjectObserver` protocol to observe detailed changes to a list's object. `ListObjectObserver`s may register themselves to a `ListMonitor`'s `addObserver(_:)` method:
``` ```
let monitor = CoreStore.monitorList( let monitor = dataStack.monitorList(
From<MyPersonEntity>(), From<MyPersonEntity>(),
OrderBy(.ascending("lastName")) OrderBy(.ascending("lastName"))
) )
@@ -169,7 +169,7 @@ extension ListObjectObserver {
/** /**
Implement the `ListSectionObserver` protocol to observe changes to a list's section info. `ListSectionObserver`s may register themselves to a `ListMonitor`'s `addObserver(_:)` method: Implement the `ListSectionObserver` protocol to observe changes to a list's section info. `ListSectionObserver`s may register themselves to a `ListMonitor`'s `addObserver(_:)` method:
``` ```
let monitor = CoreStore.monitorSectionedList( let monitor = dataStack.monitorSectionedList(
From<MyPersonEntity>(), From<MyPersonEntity>(),
SectionBy("age") { "Age \($0)" }, SectionBy("age") { "Age \($0)" },
OrderBy(.ascending("lastName")) OrderBy(.ascending("lastName"))

View File

@@ -41,7 +41,7 @@ import SwiftUI
/** /**
`ListPublisher` tracks a diffable list of `DynamicObject` instances. Unlike `ListMonitor`s, `ListPublisher` are more lightweight and access objects lazily. Objects that need to be notified of `ListPublisher` changes may register themselves to its `addObserver(_:_:)` method: `ListPublisher` tracks a diffable list of `DynamicObject` instances. Unlike `ListMonitor`s, `ListPublisher` are more lightweight and access objects lazily. Objects that need to be notified of `ListPublisher` changes may register themselves to its `addObserver(_:_:)` method:
``` ```
let listPublisher = Shared.defaultStack.listPublisher( let listPublisher = CoreStoreDefaults.dataStack.listPublisher(
From<Person>() From<Person>()
.where(\.title == "Engineer") .where(\.title == "Engineer")
.orderBy(.ascending(\.lastName)) .orderBy(.ascending(\.lastName))
@@ -55,7 +55,7 @@ import SwiftUI
`ListPublisher`s may optionally be created with sections: `ListPublisher`s may optionally be created with sections:
``` ```
let listPublisher = Shared.defaultStack.listPublisher( let listPublisher = CoreStoreDefaults.dataStack.listPublisher(
From<Person>() From<Person>()
.sectionBy(\.age") { "Age \($0)" } .sectionBy(\.age") { "Age \($0)" }
.where(\.title == "Engineer") .where(\.title == "Engineer")

View File

@@ -33,7 +33,7 @@ import Foundation
`MigrationResult.success` indicates either the migration succeeded, or there were no migrations needed. The associated value is an array of `MigrationType`s reflecting the migration steps completed. `MigrationResult.success` indicates either the migration succeeded, or there were no migrations needed. The associated value is an array of `MigrationType`s reflecting the migration steps completed.
`MigrationResult.failure` indicates that the migration failed. The associated object for this value is the a `CoreStoreError` enum value. `MigrationResult.failure` indicates that the migration failed. The associated object for this value is the a `CoreStoreError` enum value.
``` ```
CoreStore.upgradeStorageIfNeeded(SQLiteStorage(fileName: "data.sqlite")) { (result) in dataStack.upgradeStorageIfNeeded(SQLiteStorage(fileName: "data.sqlite")) { (result) in
switch result { switch result {
case .success(let migrationSteps): case .success(let migrationSteps):
// ... // ...

View File

@@ -32,7 +32,7 @@ import CoreData
/** /**
The `ObjectMonitor` monitors changes to a single `DynamicObject` instance. Observers that implement the `ObjectObserver` protocol may then register themselves to the `ObjectMonitor`'s `addObserver(_:)` method: The `ObjectMonitor` monitors changes to a single `DynamicObject` instance. Observers that implement the `ObjectObserver` protocol may then register themselves to the `ObjectMonitor`'s `addObserver(_:)` method:
``` ```
let monitor = CoreStore.monitorObject(object) let monitor = dataStack.monitorObject(object)
monitor.addObserver(self) monitor.addObserver(self)
``` ```
The created `ObjectMonitor` instance needs to be held on (retained) for as long as the object needs to be observed. The created `ObjectMonitor` instance needs to be held on (retained) for as long as the object needs to be observed.

View File

@@ -32,7 +32,7 @@ import CoreData
/** /**
Implement the `ObjectObserver` protocol to observe changes to a single `DynamicObject` instance. `ObjectObserver`s may register themselves to an `ObjectMonitor`'s `addObserver(_:)` method: Implement the `ObjectObserver` protocol to observe changes to a single `DynamicObject` instance. `ObjectObserver`s may register themselves to an `ObjectMonitor`'s `addObserver(_:)` method:
``` ```
let monitor = CoreStore.monitorObject(object) let monitor = dataStack.monitorObject(object)
monitor.addObserver(self) monitor.addObserver(self)
``` ```
*/ */

View File

@@ -41,7 +41,7 @@ import SwiftUI
/** /**
The `ObjectPublisher` tracks changes to a single `DynamicObject` instance. Objects that need to be notified of `ObjectPublisher` changes may register themselves to its `addObserver(_:_:)` method: The `ObjectPublisher` tracks changes to a single `DynamicObject` instance. Objects that need to be notified of `ObjectPublisher` changes may register themselves to its `addObserver(_:_:)` method:
``` ```
let objectPublisher = Shared.defaultStack.objectPublisher(object) let objectPublisher = CoreStoreDefaults.dataStack.objectPublisher(object)
objectPublisher.addObserver(self) { (objectPublisher) in objectPublisher.addObserver(self) { (objectPublisher) in
// Handle changes // Handle changes
} }
@@ -307,6 +307,7 @@ extension ObjectPublisher {
#if canImport(Combine) #if canImport(Combine)
#if canImport(SwiftUI) #if canImport(SwiftUI)
withAnimation { withAnimation {
self.objectWillChange.send() self.objectWillChange.send()

View File

@@ -32,7 +32,7 @@ import CoreData
/** /**
The `SectionBy` clause indicates the key path to use to group the `ListMonitor` objects into sections. An optional closure can also be provided to transform the value into an appropriate section name: The `SectionBy` clause indicates the key path to use to group the `ListMonitor` objects into sections. An optional closure can also be provided to transform the value into an appropriate section name:
``` ```
let monitor = CoreStore.monitorSectionedList( let monitor = dataStack.monitorSectionedList(
From<Person>(), From<Person>(),
SectionBy("age") { "Age \($0)" }, SectionBy("age") { "Age \($0)" },
OrderBy(.ascending("lastName")) OrderBy(.ascending("lastName"))

View File

@@ -57,7 +57,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
/** /**
Provides a `SelectTerm` to a `Select` clause for querying an entity attribute. A shorter way to do the same is to assign from the string keypath directly: Provides a `SelectTerm` to a `Select` clause for querying an entity attribute. A shorter way to do the same is to assign from the string keypath directly:
``` ```
let fullName = CoreStore.queryValue( let fullName = dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select<String>(.attribute("fullName")), Select<String>(.attribute("fullName")),
Where("employeeID", isEqualTo: 1111) Where("employeeID", isEqualTo: 1111)
@@ -65,7 +65,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
``` ```
is equivalent to: is equivalent to:
``` ```
let fullName = CoreStore.queryValue( let fullName = dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select<String>("fullName"), Select<String>("fullName"),
Where("employeeID", isEqualTo: 1111) Where("employeeID", isEqualTo: 1111)
@@ -82,7 +82,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
/** /**
Provides a `SelectTerm` to a `Select` clause for querying the average value of an attribute. Provides a `SelectTerm` to a `Select` clause for querying the average value of an attribute.
``` ```
let averageAge = CoreStore.queryValue( let averageAge = dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select<Int>(.average("age")) Select<Int>(.average("age"))
) )
@@ -104,7 +104,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
/** /**
Provides a `SelectTerm` to a `Select` clause for a count query. Provides a `SelectTerm` to a `Select` clause for a count query.
``` ```
let numberOfEmployees = CoreStore.queryValue( let numberOfEmployees = dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select<Int>(.count("employeeID")) Select<Int>(.count("employeeID"))
) )
@@ -126,7 +126,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
/** /**
Provides a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute. Provides a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute.
``` ```
let maximumAge = CoreStore.queryValue( let maximumAge = dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select<Int>(.maximum("age")) Select<Int>(.maximum("age"))
) )
@@ -148,7 +148,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
/** /**
Provides a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute. Provides a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute.
``` ```
let minimumAge = CoreStore.queryValue( let minimumAge = dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select<Int>(.minimum("age")) Select<Int>(.minimum("age"))
) )
@@ -170,7 +170,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
/** /**
Provides a `SelectTerm` to a `Select` clause for querying the sum value for an attribute. Provides a `SelectTerm` to a `Select` clause for querying the sum value for an attribute.
``` ```
let totalAge = CoreStore.queryValue( let totalAge = dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select<Int>(.sum("age")) Select<Int>(.sum("age"))
) )
@@ -192,7 +192,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
/** /**
Provides a `SelectTerm` to a `Select` clause for querying the `NSManagedObjectID`. Provides a `SelectTerm` to a `Select` clause for querying the `NSManagedObjectID`.
``` ```
let objectID = CoreStore.queryValue( let objectID = dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select<NSManagedObjectID>(), Select<NSManagedObjectID>(),
Where("employeeID", isEqualTo: 1111) Where("employeeID", isEqualTo: 1111)
@@ -651,14 +651,14 @@ extension SelectTerm where D: CoreStoreObject {
You can bind the return type by specializing the initializer: You can bind the return type by specializing the initializer:
``` ```
let maximumAge = CoreStore.queryValue( let maximumAge = dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select<Int>(.maximum("age")) Select<Int>(.maximum("age"))
) )
``` ```
or by casting the type of the return value: or by casting the type of the return value:
``` ```
let maximumAge: Int = CoreStore.queryValue( let maximumAge: Int = dataStack.queryValue(
From<MyPersonEntity>(), From<MyPersonEntity>(),
Select(.maximum("age")) Select(.maximum("age"))
) )

View File

@@ -34,7 +34,7 @@ import CoreData
`SetupResult.success` indicates that the storage setup succeeded. The associated object for this `enum` value is the related `StorageInterface` instance. `SetupResult.success` indicates that the storage setup succeeded. The associated object for this `enum` value is the related `StorageInterface` instance.
`SetupResult.failure` indicates that the storage setup failed. The associated object for this value is the related `CoreStoreError` enum value. `SetupResult.failure` indicates that the storage setup failed. The associated object for this value is the related `CoreStoreError` enum value.
``` ```
try! CoreStore.addStorage( try! dataStack.addStorage(
SQLiteStore(), SQLiteStore(),
completion: { (result: SetupResult) -> Void in completion: { (result: SetupResult) -> Void in
switch result { switch result {

View File

@@ -30,7 +30,7 @@ import CoreData
// MARK: - SynchronousDataTransaction // MARK: - SynchronousDataTransaction
/** /**
The `SynchronousDataTransaction` 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.beginSynchronous(_:)`, or from `CoreStore.beginSynchronous(_:)`. The `SynchronousDataTransaction` 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.beginSynchronous(_:)`.
*/ */
public final class SynchronousDataTransaction: BaseDataTransaction { public final class SynchronousDataTransaction: BaseDataTransaction {

View File

@@ -37,7 +37,7 @@ public final class UnsafeDataModelSchema: DynamicSchema {
/** /**
Initializes a `UnsafeDataModelSchema` from an `NSManagedObjectModel`. Initializes a `UnsafeDataModelSchema` from an `NSManagedObjectModel`.
``` ```
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
UnsafeDataModelSchema(modelName: "MyAppV1", model: model) UnsafeDataModelSchema(modelName: "MyAppV1", model: model)
) )
``` ```

View File

@@ -34,7 +34,7 @@ import Foundation
enum Static { enum Static {
static var myDataKey: Void? static var myDataKey: Void?
} }
CoreStore.defaultStack.userInfo[&Static.myDataKey] = myObject CoreStoreDefaults.dataStack.userInfo[&Static.myDataKey] = myObject
``` ```
- Important: Do not use this class to store thread-sensitive data. - Important: Do not use this class to store thread-sensitive data.
*/ */
@@ -46,7 +46,7 @@ public final class UserInfo {
enum Static { enum Static {
static var myDataKey: Void? static var myDataKey: Void?
} }
CoreStore.defaultStack.userInfo[&Static.myDataKey] = myObject CoreStoreDefaults.dataStack.userInfo[&Static.myDataKey] = myObject
``` ```
- Important: Do not use this method to store thread-sensitive data. - Important: Do not use this method to store thread-sensitive data.
- parameter key: the key for custom data. Make sure this is a static pointer that will never be changed. - parameter key: the key for custom data. Make sure this is a static pointer that will never be changed.
@@ -79,7 +79,7 @@ public final class UserInfo {
enum Static { enum Static {
static var myDataKey: Void? static var myDataKey: Void?
} }
CoreStore.defaultStack.userInfo[&Static.myDataKey, lazyInit: { MyObject() }] = myObject CoreStoreDefaults.dataStack.userInfo[&Static.myDataKey, lazyInit: { MyObject() }] = myObject
``` ```
- Important: Do not use this method to store thread-sensitive data. - Important: Do not use this method to store thread-sensitive data.
- parameter key: the key for custom data. Make sure this is a static pointer that will never be changed. - parameter key: the key for custom data. Make sure this is a static pointer that will never be changed.

View File

@@ -41,7 +41,7 @@ import Foundation
let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master }) let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master })
} }
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
CoreStoreSchema( CoreStoreSchema(
modelVersion: "V1", modelVersion: "V1",
entities: [ entities: [

View File

@@ -32,7 +32,7 @@ import CoreData
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let owner = CoreStore.fetchOne( let owner = dataStack.fetchOne(
From<Pet>().where( From<Pet>().where(
(\.master ~ \.name) == "John" (\.master ~ \.name) == "John"
) )
@@ -60,7 +60,7 @@ extension Where {
Type-safe keyPath chain usable in query/fetch expressions. Type-safe keyPath chain usable in query/fetch expressions.
``` ```
let expression: Where<Pet>.Expression = (\.master ~ \.name) let expression: Where<Pet>.Expression = (\.master ~ \.name)
let owner = CoreStore.fetchOne( let owner = dataStack.fetchOne(
From<Pet>().where(expression == "John") From<Pet>().where(expression == "John")
) )
``` ```
@@ -130,7 +130,7 @@ extension Where {
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let owner = CoreStore.fetchOne(From<Pet>().where((\.master ~ \.name) == "John")) let owner = dataStack.fetchOne(From<Pet>().where((\.master ~ \.name) == "John"))
``` ```
*/ */
public func ~<D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCKeyPathValue>(_ lhs: KeyPath<D, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.SingleTarget, V> { public func ~<D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCKeyPathValue>(_ lhs: KeyPath<D, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.SingleTarget, V> {
@@ -141,7 +141,7 @@ public func ~<D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCKeyPat
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let owner = CoreStore.fetchOne(From<Pet>().where((\.master ~ \.name) == "John")) let owner = dataStack.fetchOne(From<Pet>().where((\.master ~ \.name) == "John"))
``` ```
*/ */
public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCKeyPathValue>(_ lhs: KeyPath<D, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.SingleTarget, V> { public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCKeyPathValue>(_ lhs: KeyPath<D, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.SingleTarget, V> {
@@ -152,7 +152,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCKeyPa
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let happyPets = CoreStore.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1)) let happyPets = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1))
``` ```
*/ */
public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: KeyPath<D, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> { public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: KeyPath<D, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> {
@@ -163,7 +163,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCToMan
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let happyPets = CoreStore.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1)) let happyPets = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1))
``` ```
*/ */
public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: KeyPath<D, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> { public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: KeyPath<D, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> {
@@ -174,7 +174,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCToMan
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let johnsSonInLaw = CoreStore.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.name) == "John")) let johnsSonInLaw = dataStack.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.name) == "John"))
``` ```
*/ */
public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<T, V> { public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<T, V> {
@@ -185,7 +185,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCKe
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let johnsSonInLaw = CoreStore.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.name) == "John")) let johnsSonInLaw = dataStack.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.name) == "John"))
``` ```
*/ */
public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<T, V> { public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<T, V> {
@@ -196,7 +196,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCKe
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let spouseHasSiblings = CoreStore.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.children).count() > 0)) let spouseHasSiblings = dataStack.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.children).count() > 0))
``` ```
*/ */
public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> { public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> {
@@ -207,7 +207,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCTo
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let spouseHasSiblings = CoreStore.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.children).count() > 0)) let spouseHasSiblings = dataStack.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.children).count() > 0))
``` ```
*/ */
public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> { public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> {
@@ -218,7 +218,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCTo
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let spousesWithBadNamingSense = CoreStore.fetchAll(From<Person>().where((\.spouse ~ \.pets ~ \.name).any() == "Spot")) let spousesWithBadNamingSense = dataStack.fetchAll(From<Person>().where((\.spouse ~ \.pets ~ \.name).any() == "Spot"))
``` ```
*/ */
public func ~ <D: NSManagedObject, O: NSManagedObject, T, C: AllowedObjectiveCToManyRelationshipKeyPathValue, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<D>.Expression<T, C>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> { public func ~ <D: NSManagedObject, O: NSManagedObject, T, C: AllowedObjectiveCToManyRelationshipKeyPathValue, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<D>.Expression<T, C>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> {
@@ -232,7 +232,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, T, C: AllowedObjectiveCTo
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let owner = CoreStore.fetchOne(From<Pet>().where((\.master ~ \.name) == "John")) let owner = dataStack.fetchOne(From<Pet>().where((\.master ~ \.name) == "John"))
``` ```
*/ */
public func ~ <D: CoreStoreObject, O: CoreStoreObject, K: KeyPathStringConvertible>(_ lhs: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.SingleTarget, K.DestinationValueType> where K.ObjectType == O { public func ~ <D: CoreStoreObject, O: CoreStoreObject, K: KeyPathStringConvertible>(_ lhs: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.SingleTarget, K.DestinationValueType> where K.ObjectType == O {
@@ -246,7 +246,7 @@ public func ~ <D: CoreStoreObject, O: CoreStoreObject, K: KeyPathStringConvertib
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let owner = CoreStore.fetchOne(From<Pet>().where((\.master ~ \.name) == "John")) let owner = dataStack.fetchOne(From<Pet>().where((\.master ~ \.name) == "John"))
``` ```
*/ */
public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: KeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<T, K.DestinationValueType> where K.ObjectType == O { public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: KeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<T, K.DestinationValueType> where K.ObjectType == O {
@@ -260,7 +260,7 @@ public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: KeyPathStringConver
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let owner = CoreStore.fetchOne(From<Pet>().where((\.master ~ \.name) == "John")) let owner = dataStack.fetchOne(From<Pet>().where((\.master ~ \.name) == "John"))
``` ```
*/ */
public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: KeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<T, K.DestinationValueType> where K.ObjectType == O { public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: KeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<T, K.DestinationValueType> where K.ObjectType == O {
@@ -274,7 +274,7 @@ public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: KeyPathStringConver
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let happyPets = CoreStore.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1)) let happyPets = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1))
``` ```
*/ */
public func ~ <D: CoreStoreObject, O: CoreStoreObject, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.CollectionTarget, K.DestinationValueType> where K.ObjectType == O { public func ~ <D: CoreStoreObject, O: CoreStoreObject, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.CollectionTarget, K.DestinationValueType> where K.ObjectType == O {
@@ -288,7 +288,7 @@ public func ~ <D: CoreStoreObject, O: CoreStoreObject, K: ToManyRelationshipKeyP
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let happyPets = CoreStore.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1)) let happyPets = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1))
``` ```
*/ */
public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.CollectionTarget, K.DestinationValueType> where K.ObjectType == O { public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.CollectionTarget, K.DestinationValueType> where K.ObjectType == O {
@@ -302,7 +302,7 @@ public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: ToManyRelationshipK
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let happyPets = CoreStore.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1)) let happyPets = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1))
``` ```
*/ */
public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.CollectionTarget, K.DestinationValueType> where K.ObjectType == O { public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.CollectionTarget, K.DestinationValueType> where K.ObjectType == O {
@@ -316,7 +316,7 @@ public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: ToManyRelationshipK
/** /**
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
``` ```
let spousesWithBadNamingSense = CoreStore.fetchAll(From<Pet>().where((\.master ~ \.pets ~ \.name).any() == "Spot")) let spousesWithBadNamingSense = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets ~ \.name).any() == "Spot"))
``` ```
*/ */
public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, KC: ToManyRelationshipKeyPathStringConvertible, KV: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, KC>, _ rhs: KeyPath<O, KV>) -> Where<D>.Expression<Where<D>.CollectionTarget, KV.DestinationValueType> where KC.ObjectType == D, KV.ObjectType == O { public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, KC: ToManyRelationshipKeyPathStringConvertible, KV: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, KC>, _ rhs: KeyPath<O, KV>) -> Where<D>.Expression<Where<D>.CollectionTarget, KV.DestinationValueType> where KC.ObjectType == D, KV.ObjectType == O {
@@ -333,7 +333,7 @@ public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, KC: ToManyRelationship
/** /**
Creates a `Where` clause by comparing if an expression is equal to a value Creates a `Where` clause by comparing if an expression is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.name) == "John")) let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) == "John"))
``` ```
*/ */
public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> { public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
@@ -344,7 +344,7 @@ public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
/** /**
Creates a `Where` clause by comparing if an expression is not equal to a value Creates a `Where` clause by comparing if an expression is not equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.name) != "John")) let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) != "John"))
``` ```
*/ */
public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> { public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
@@ -355,7 +355,7 @@ public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
/** /**
Creates a `Where` clause by checking if a sequence contains a value Creates a `Where` clause by checking if a sequence contains a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(["John", "Joe"] ~= (\.master ~ \.name)) let dog = dataStack.fetchOne(From<Dog>().where(["John", "Joe"] ~= (\.master ~ \.name))
``` ```
*/ */
public func ~= <D, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ expression: Where<D>.Expression<T, V>) -> Where<D> where S.Iterator.Element == V { public func ~= <D, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ expression: Where<D>.Expression<T, V>) -> Where<D> where S.Iterator.Element == V {
@@ -369,7 +369,7 @@ public func ~= <D, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ e
/** /**
Creates a `Where` clause by comparing if an expression is less than a value Creates a `Where` clause by comparing if an expression is less than a value
``` ```
let lonelyDog = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.pets).count() < 2)) let lonelyDog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.pets).count() < 2))
``` ```
*/ */
public func < <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> { public func < <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
@@ -380,7 +380,7 @@ public func < <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Exp
/** /**
Creates a `Where` clause by comparing if an expression is less than or equal to a value Creates a `Where` clause by comparing if an expression is less than or equal to a value
``` ```
let lonelyDog = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.pets).count() <= 1) let lonelyDog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.pets).count() <= 1)
``` ```
*/ */
public func <= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> { public func <= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
@@ -391,7 +391,7 @@ public func <= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Ex
/** /**
Creates a `Where` clause by comparing if an expression is greater than a value Creates a `Where` clause by comparing if an expression is greater than a value
``` ```
let happyDog = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.pets).count() > 1) let happyDog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.pets).count() > 1)
``` ```
*/ */
public func > <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> { public func > <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
@@ -402,7 +402,7 @@ public func > <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Exp
/** /**
Creates a `Where` clause by comparing if an expression is greater than or equal to a value Creates a `Where` clause by comparing if an expression is greater than or equal to a value
``` ```
let happyDog = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.pets).count() >= 2) let happyDog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.pets).count() >= 2)
``` ```
*/ */
public func >= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> { public func >= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
@@ -416,7 +416,7 @@ public func >= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Ex
/** /**
Creates a `Where` clause by comparing if an expression is equal to a value Creates a `Where` clause by comparing if an expression is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.name) == "John")) let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) == "John"))
``` ```
*/ */
public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> { public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> {
@@ -427,7 +427,7 @@ public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
/** /**
Creates a `Where` clause by comparing if an expression is equal to a value Creates a `Where` clause by comparing if an expression is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.name) == "John")) let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) == "John"))
``` ```
*/ */
public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> { public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> {
@@ -438,7 +438,7 @@ public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
/** /**
Creates a `Where` clause by comparing if an expression is equal to a value Creates a `Where` clause by comparing if an expression is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.name) != "John")) let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) != "John"))
``` ```
*/ */
public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> { public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> {
@@ -449,7 +449,7 @@ public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
/** /**
Creates a `Where` clause by comparing if an expression is equal to a value Creates a `Where` clause by comparing if an expression is equal to a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.name) != "John")) let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) != "John"))
``` ```
*/ */
public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> { public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> {
@@ -460,7 +460,7 @@ public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
/** /**
Creates a `Where` clause by checking if a sequence contains a value Creates a `Where` clause by checking if a sequence contains a value
``` ```
let dog = CoreStore.fetchOne(From<Dog>().where(["John", "Joe"] ~= (\.master ~ \.name)) let dog = dataStack.fetchOne(From<Dog>().where(["John", "Joe"] ~= (\.master ~ \.name))
``` ```
*/ */
public func ~= <D, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ expression: Where<D>.Expression<T, V?>) -> Where<D> where S.Iterator.Element == V { public func ~= <D, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ expression: Where<D>.Expression<T, V?>) -> Where<D> where S.Iterator.Element == V {
@@ -474,7 +474,7 @@ public func ~= <D, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ e
/** /**
Creates a `Where` clause by comparing if an expression is less than a value Creates a `Where` clause by comparing if an expression is less than a value
``` ```
let childsPet = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.age) < 10)) let childsPet = dataStack.fetchOne(From<Dog>().where((\.master ~ \.age) < 10))
``` ```
*/ */
public func < <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> { public func < <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> {
@@ -485,7 +485,7 @@ public func < <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Exp
/** /**
Creates a `Where` clause by comparing if an expression is less than or equal to a value Creates a `Where` clause by comparing if an expression is less than or equal to a value
``` ```
let childsPet = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.age) <= 10)) let childsPet = dataStack.fetchOne(From<Dog>().where((\.master ~ \.age) <= 10))
``` ```
*/ */
public func <= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> { public func <= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> {
@@ -496,7 +496,7 @@ public func <= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Ex
/** /**
Creates a `Where` clause by comparing if an expression is greater than a value Creates a `Where` clause by comparing if an expression is greater than a value
``` ```
let teensPet = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.age) > 10)) let teensPet = dataStack.fetchOne(From<Dog>().where((\.master ~ \.age) > 10))
``` ```
*/ */
public func > <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> { public func > <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> {
@@ -507,7 +507,7 @@ public func > <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Exp
/** /**
Creates a `Where` clause by comparing if an expression is greater than or equal to a value Creates a `Where` clause by comparing if an expression is greater than or equal to a value
``` ```
let teensPet = CoreStore.fetchOne(From<Dog>().where((\.master ~ \.age) >= 10)) let teensPet = dataStack.fetchOne(From<Dog>().where((\.master ~ \.age) >= 10))
``` ```
*/ */
public func >= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> { public func >= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> {
@@ -523,7 +523,7 @@ extension KeyPath where Root: NSManagedObject, Value: AllowedObjectiveCToManyRel
/** /**
Creates a `Where.Expression` clause for COUNT Creates a `Where.Expression` clause for COUNT
``` ```
let dogsWithPlaymates = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1)) let dogsWithPlaymates = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1))
``` ```
*/ */
public func count() -> Where<Root>.Expression<Where<Root>.CollectionTarget, Int> { public func count() -> Where<Root>.Expression<Where<Root>.CollectionTarget, Int> {
@@ -539,7 +539,7 @@ extension Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTar
/** /**
Creates a `Where.Expression` clause for COUNT Creates a `Where.Expression` clause for COUNT
``` ```
let dogsWithPlaymates = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1)) let dogsWithPlaymates = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1))
``` ```
*/ */
public func count() -> Where<D>.Expression<T, Int> { public func count() -> Where<D>.Expression<T, Int> {
@@ -556,7 +556,7 @@ extension Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTar
/** /**
Creates a `Where.Expression` clause for ANY Creates a `Where.Expression` clause for ANY
``` ```
let dogsWithBadNamingSense = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot")) let dogsWithBadNamingSense = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))
``` ```
*/ */
public func any() -> Where<D>.Expression<T, V> { public func any() -> Where<D>.Expression<T, V> {
@@ -567,7 +567,7 @@ extension Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTar
/** /**
Creates a `Where.Expression` clause for ALL Creates a `Where.Expression` clause for ALL
``` ```
let allPlaymatePuppies = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.age).all() > 5)) let allPlaymatePuppies = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.age).all() > 5))
``` ```
*/ */
public func all() -> Where<D>.Expression<T, V> { public func all() -> Where<D>.Expression<T, V> {
@@ -578,7 +578,7 @@ extension Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTar
/** /**
Creates a `Where.Expression` clause for NONE Creates a `Where.Expression` clause for NONE
``` ```
let dogs = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot")) let dogs = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))
``` ```
*/ */
public func none() -> Where<D>.Expression<T, V> { public func none() -> Where<D>.Expression<T, V> {
@@ -595,7 +595,7 @@ extension KeyPath where Root: CoreStoreObject, Value: ToManyRelationshipKeyPathS
/** /**
Creates a `Where.Expression` clause for COUNT Creates a `Where.Expression` clause for COUNT
``` ```
let dogsWithPlaymates = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1)) let dogsWithPlaymates = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1))
``` ```
*/ */
public func count() -> Where<Root>.Expression<Where<Root>.CollectionTarget, Int> { public func count() -> Where<Root>.Expression<Where<Root>.CollectionTarget, Int> {
@@ -612,7 +612,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where<D>.CollectionTar
/** /**
Creates a `Where.Expression` clause for COUNT Creates a `Where.Expression` clause for COUNT
``` ```
let dogsWithPlaymates = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1)) let dogsWithPlaymates = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1))
``` ```
*/ */
public func count() -> Where<D>.Expression<T, Int> { public func count() -> Where<D>.Expression<T, Int> {
@@ -623,7 +623,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where<D>.CollectionTar
/** /**
Creates a `Where.Expression` clause for ANY Creates a `Where.Expression` clause for ANY
``` ```
let dogsWithBadNamingSense = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot")) let dogsWithBadNamingSense = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))
``` ```
*/ */
public func any() -> Where<D>.Expression<T, V> { public func any() -> Where<D>.Expression<T, V> {
@@ -634,7 +634,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where<D>.CollectionTar
/** /**
Creates a `Where.Expression` clause for ALL Creates a `Where.Expression` clause for ALL
``` ```
let allPlaymatePuppies = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.age).all() > 5)) let allPlaymatePuppies = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.age).all() > 5))
``` ```
*/ */
public func all() -> Where<D>.Expression<T, V> { public func all() -> Where<D>.Expression<T, V> {
@@ -645,7 +645,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where<D>.CollectionTar
/** /**
Creates a `Where.Expression` clause for NONE Creates a `Where.Expression` clause for NONE
``` ```
let dogs = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot")) let dogs = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))
``` ```
*/ */
public func none() -> Where<D>.Expression<T, V> { public func none() -> Where<D>.Expression<T, V> {

View File

@@ -32,7 +32,7 @@ import Foundation
/** /**
The `XcodeDataModelSchema` describes a model version declared in a single *.xcdatamodeld file. The `XcodeDataModelSchema` describes a model version declared in a single *.xcdatamodeld file.
``` ```
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
XcodeDataModelSchema(modelName: "MyAppV1", bundle: .main) XcodeDataModelSchema(modelName: "MyAppV1", bundle: .main)
) )
``` ```
@@ -109,7 +109,7 @@ public final class XcodeDataModelSchema: DynamicSchema {
/** /**
Initializes an `XcodeDataModelSchema` from an *.xcdatamodeld version name and its containing `Bundle`. Initializes an `XcodeDataModelSchema` from an *.xcdatamodeld version name and its containing `Bundle`.
``` ```
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
XcodeDataModelSchema(modelName: "MyAppV1", bundle: .main) XcodeDataModelSchema(modelName: "MyAppV1", bundle: .main)
) )
``` ```
@@ -135,7 +135,7 @@ public final class XcodeDataModelSchema: DynamicSchema {
/** /**
Initializes an `XcodeDataModelSchema` from an *.xcdatamodeld file URL. Initializes an `XcodeDataModelSchema` from an *.xcdatamodeld file URL.
``` ```
CoreStore.defaultStack = DataStack( CoreStoreDefaults.dataStack = DataStack(
XcodeDataModelSchema(modelName: "MyAppV1", modelVersionFileURL: fileURL) XcodeDataModelSchema(modelName: "MyAppV1", modelVersionFileURL: fileURL)
) )
``` ```

View File

@@ -0,0 +1,294 @@
//
// DiffableDataSource.CollectionView-AppKit.swift
// CoreStore
//
// Copyright © 2018 John Rommel Estropia
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
#if canImport(AppKit) && os(macOS)
import AppKit
import CoreData
// MARK: - DiffableDataSource
extension DiffableDataSource {
// MARK: - CollectionView
/**
The `DiffableDataSource.CollectionView` serves as a `NSCollectionViewDataSource` that handles `ListPublisher` snapshots for a `NSCollectionView`. Subclasses of `DiffableDataSource.CollectionView` may override some `NSCollectionViewDataSource` methods as needed.
The `DiffableDataSource.CollectionView` instance needs to be held on (retained) for as long as the `NSCollectionView`'s lifecycle.
```
self.dataSource = DiffableDataSource.CollectionView<Person>(
collectionView: self.collectionView,
dataStack: CoreStoreDefaults.dataStack,
itemProvider: { (collectionView, indexPath, person) in
let item = collectionView.makeItem(withIdentifier: .collectionViewItem, for: indexPath) as! PersonItem
item.setPerson(person)
return item
}
)
```
The dataSource can then apply changes from a `ListPublisher` as shown:
```
listPublisher.addObserver(self) { [weak self] (listPublisher) in
self?.dataSource?.apply(
listPublisher.snapshot,
animatingDifferences: true
)
}
```
`DiffableDataSource.CollectionView` fully handles the reload animations.
*/
open class CollectionView<O: DynamicObject>: NSObject, NSCollectionViewDataSource {
// MARK: Public
/**
The object type represented by this dataSource
*/
public typealias ObjectType = O
/**
Initializes the `DiffableDataSource.CollectionView`. This instance needs to be held on (retained) for as long as the `NSCollectionView`'s lifecycle.
```
self.dataSource = DiffableDataSource.CollectionView<Person>(
collectionView: self.collectionView,
dataStack: CoreStoreDefaults.dataStack,
itemProvider: { (collectionView, indexPath, person) in
let item = collectionView.makeItem(withIdentifier: .collectionViewItem, for: indexPath) as! PersonItem
item.setPerson(person)
return item
}
)
```
- parameter collectionView: the `NSCollectionView` to set the `dataSource` of. This instance is not retained by the `DiffableDataSource.CollectionView`.
- parameter dataStack: the `DataStack` instance that the dataSource will fetch objects from
- parameter itemProvider: a closure that configures and returns the `NSCollectionViewItem` for the object
*/
@nonobjc
public init(collectionView: NSCollectionView, dataStack: DataStack, itemProvider: @escaping (NSCollectionView, IndexPath, O) -> NSCollectionViewItem?, supplementaryViewProvider: @escaping (NSCollectionView, String, IndexPath) -> NSView? = { _, _, _ in nil }) {
self.collectionView = collectionView
self.itemProvider = itemProvider
self.supplementaryViewProvider = supplementaryViewProvider
self.dataStack = dataStack
self.dispatcher = Internals.DiffableDataUIDispatcher<O>(dataStack: dataStack)
super.init()
collectionView.dataSource = self
}
/**
Reloads the `NSCollectionView` using a `ListSnapshot`. This is typically from the `snapshot` property of a `ListPublisher`:
```
listPublisher.addObserver(self) { [weak self] (listPublisher) in
self?.dataSource?.apply(
listPublisher.snapshot,
animatingDifferences: true
)
}
```
- parameter snapshot: the `ListSnapshot` used to reload the `UITableView` with. This is typically from the `snapshot` property of a `ListPublisher`.
- parameter animatingDifferences: if `true`, animations will be applied as configured by the `defaultRowAnimation` value. Defaults to `true`.
*/
public func apply(_ snapshot: ListSnapshot<O>, animatingDifferences: Bool = true) {
let diffableSnapshot = snapshot.diffableSnapshot
self.dispatcher.apply(
diffableSnapshot as! Internals.DiffableDataSourceSnapshot,
view: self.collectionView,
animatingDifferences: animatingDifferences,
performUpdates: { collectionView, changeset, setSections in
collectionView.reload(
using: changeset,
setData: setSections
)
}
)
}
/**
Returns the object identifier for the item at the specified `IndexPath`, or `nil` if not found
- parameter indexPath: the `IndexPath` to search for
- returns: the object identifier for the item at the specified `IndexPath`, or `nil` if not found
*/
@nonobjc
public func itemID(for indexPath: IndexPath) -> O.ObjectID? {
return self.dispatcher.itemIdentifier(for: indexPath)
}
/**
Returns the `IndexPath` for the item with the specified object identifier, or `nil` if not found
- parameter itemID: the object identifier to search for
- returns: the `IndexPath` for the item with the specified object identifier, or `nil` if not found
*/
@nonobjc
public func indexPath(for itemID: O.ObjectID) -> IndexPath? {
return self.dispatcher.indexPath(for: itemID)
}
// MARK: - NSCollectionViewDataSource
@objc
public dynamic func numberOfSections(in collectionView: NSCollectionView) -> Int {
return self.dispatcher.numberOfSections()
}
@objc
public dynamic func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
return self.dispatcher.numberOfItems(inSection: section)
}
@objc
open dynamic func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
guard let objectID = self.dispatcher.itemIdentifier(for: indexPath) else {
Internals.abort("Object at \(Internals.typeName(IndexPath.self)) \(indexPath) already removed from list")
}
guard let object = self.dataStack.fetchExisting(objectID) as O? else {
Internals.abort("Object at \(Internals.typeName(IndexPath.self)) \(indexPath) has been deleted")
}
guard let item = self.itemProvider(collectionView, indexPath, object) else {
Internals.abort("\(Internals.typeName(NSCollectionViewDataSource.self)) returned a `nil` item for \(Internals.typeName(IndexPath.self)) \(indexPath)")
}
return item
}
@objc
open dynamic func collectionView(_ collectionView: NSCollectionView, viewForSupplementaryElementOfKind kind: NSCollectionView.SupplementaryElementKind, at indexPath: IndexPath) -> NSView {
guard let view = self.supplementaryViewProvider(collectionView, kind, indexPath) else {
return NSView()
}
return view
}
// MARK: Private
private weak var collectionView: NSCollectionView?
private let dataStack: DataStack
private let itemProvider: (NSCollectionView, IndexPath, O) -> NSCollectionViewItem?
private let supplementaryViewProvider: (NSCollectionView, String, IndexPath) -> NSView?
private let dispatcher: Internals.DiffableDataUIDispatcher<O>
}
}
// MARK: - NSCollectionView
extension NSCollectionView {
// MARK: FilePrivate
@nonobjc
fileprivate func reload<C, O>(
using stagedChangeset: Internals.DiffableDataUIDispatcher<O>.StagedChangeset<C>,
interrupt: ((Internals.DiffableDataUIDispatcher<O>.Changeset<C>) -> Bool)? = nil,
setData: (C) -> Void
) {
if case .none = window, let data = stagedChangeset.last?.data {
setData(data)
self.reloadData()
return
}
for changeset in stagedChangeset {
if let interrupt = interrupt, interrupt(changeset), let data = stagedChangeset.last?.data {
setData(data)
self.reloadData()
return
}
self.animator().performBatchUpdates(
{
setData(changeset.data)
if !changeset.sectionDeleted.isEmpty {
self.deleteSections(IndexSet(changeset.sectionDeleted))
}
if !changeset.sectionInserted.isEmpty {
self.insertSections(IndexSet(changeset.sectionInserted))
}
if !changeset.sectionUpdated.isEmpty {
self.reloadSections(IndexSet(changeset.sectionUpdated))
}
for (source, target) in changeset.sectionMoved {
self.moveSection(source, toSection: target)
}
if !changeset.elementDeleted.isEmpty {
self.deleteItems(
at: Set(changeset.elementDeleted.map { IndexPath(item: $0.element, section: $0.section) })
)
}
if !changeset.elementInserted.isEmpty {
self.insertItems(
at: Set(changeset.elementInserted.map { IndexPath(item: $0.element, section: $0.section) })
)
}
if !changeset.elementUpdated.isEmpty {
self.reloadItems(
at: Set(changeset.elementUpdated.map { IndexPath(item: $0.element, section: $0.section) })
)
}
for (source, target) in changeset.elementMoved {
self.moveItem(
at: IndexPath(item: source.element, section: source.section),
to: IndexPath(item: target.element, section: target.section)
)
}
},
completionHandler: nil
)
}
}
}
#endif

View File

@@ -1,103 +0,0 @@
---
format_version: '7'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: ios
trigger_map:
- push_branch: "*"
workflow: ci
- pull_request_source_branch: "*"
workflow: ci
workflows:
ci:
steps:
- activate-ssh-key:
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
- git-clone: {}
- cache-pull: {}
- certificate-and-profile-installer: {}
################ PLATFORM = tvOS
- xcode-test:
inputs:
- project_path: "$BITRISE_PROJECT_PATH"
- scheme: "CoreStore tvOS"
- is_clean_build: "yes"
- xcodebuild_test_options: "-configuration Debug"
- simulator_platform: "tvOS Simulator"
- simulator_device: "Apple TV"
- should_retry_test_on_fail: "yes"
- xcode-test:
inputs:
- project_path: "$BITRISE_PROJECT_PATH"
- scheme: "CoreStore tvOS"
- is_clean_build: "yes"
- xcodebuild_test_options: "-configuration Release"
- simulator_platform: "tvOS Simulator"
- simulator_device: "Apple TV"
- should_retry_test_on_fail: "yes"
- xcode-test:
inputs:
- project_path: "$BITRISE_PROJECT_PATH"
- scheme: "CoreStore tvOS"
- is_clean_build: "yes"
- simulator_platform: "tvOS Simulator"
- simulator_device: "Apple TV 4K"
- should_retry_test_on_fail: "yes"
- xcode-test:
inputs:
- project_path: "$BITRISE_PROJECT_PATH"
- scheme: "CoreStore tvOS"
- is_clean_build: "yes"
- simulator_platform: "tvOS Simulator"
- simulator_device: "Apple TV 4K (at 1080p)"
- should_retry_test_on_fail: "yes"
################ PLATFORM = iOS
- xcode-test:
inputs:
- project_path: "$BITRISE_PROJECT_PATH"
- scheme: "CoreStore iOS"
- is_clean_build: "yes"
- simulator_platform: "iOS Simulator"
- simulator_device: "iPhone XS"
- simulator_os_version: "12.0"
- should_retry_test_on_fail: "yes"
- xcode-test:
inputs:
- project_path: "$BITRISE_PROJECT_PATH"
- scheme: "CoreStore iOS"
- is_clean_build: "yes"
- simulator_platform: "iOS Simulator"
- simulator_device: "iPhone 8"
- simulator_os_version: "11.4"
- should_retry_test_on_fail: "yes"
- xcode-test:
inputs:
- project_path: "$BITRISE_PROJECT_PATH"
- scheme: "CoreStore iOS"
- is_clean_build: "yes"
- simulator_platform: "iOS Simulator"
- simulator_device: "iPhone 7"
- simulator_os_version: "10.3.1"
- should_retry_test_on_fail: "yes"
################ PLATFORM = macOS
- xcode-test-mac:
inputs:
- project_path: "$BITRISE_PROJECT_PATH"
- scheme: "CoreStore OSX"
- is_clean_build: "yes"
- xcodebuild_test_options: "-configuration Debug"
- destination: "platform=macos,arch=x86_64"
- should_retry_test_on_fail: "yes"
- xcode-test-mac:
inputs:
- project_path: "$BITRISE_PROJECT_PATH"
- scheme: "CoreStore OSX"
- is_clean_build: "yes"
- xcodebuild_test_options: "-configuration Release"
- destination: "platform=macos,arch=x86_64"
- should_retry_test_on_fail: "yes"
- cache-push: {}
app:
envs:
- opts:
is_expand: false
BITRISE_PROJECT_PATH: CoreStore.xcworkspace