mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-05-26 17:39:47 +02:00
WIP: broken generics
This commit is contained in:
@@ -340,16 +340,12 @@
|
||||
B56321B41BD6521C006C9394 /* NSManagedObjectContext+Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F331AFF85470064E85B /* NSManagedObjectContext+Transaction.swift */; };
|
||||
B56321B51BD6521C006C9394 /* NSManagedObjectModel+Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51BE0691B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift */; };
|
||||
B56321B61BD6521C006C9394 /* WeakObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F2D1AFF849C0064E85B /* WeakObject.swift */; };
|
||||
B56507901D393087000596DA /* GCDKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B565078F1D393087000596DA /* GCDKit.framework */; };
|
||||
B56507921D3930B5000596DA /* GCDKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507911D3930B5000596DA /* GCDKit.framework */; };
|
||||
B56507941D3930BC000596DA /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507931D3930BC000596DA /* CoreData.framework */; };
|
||||
B56507961D3930C1000596DA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507951D3930C1000596DA /* Foundation.framework */; };
|
||||
B56507981D3930CC000596DA /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507971D3930CC000596DA /* CoreData.framework */; };
|
||||
B565079A1D3930D1000596DA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507991D3930D1000596DA /* Foundation.framework */; };
|
||||
B565079C1D3930D8000596DA /* GCDKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B565079B1D3930D8000596DA /* GCDKit.framework */; };
|
||||
B565079E1D3930ED000596DA /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B565079D1D3930ED000596DA /* CoreData.framework */; };
|
||||
B56507A01D3930F5000596DA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B565079F1D3930F5000596DA /* Foundation.framework */; };
|
||||
B56507A21D393101000596DA /* GCDKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B56507A11D393101000596DA /* GCDKit.framework */; };
|
||||
B5677D3D1CD3B1E400322BFC /* ICloudStoreObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5677D3C1CD3B1E400322BFC /* ICloudStoreObserver.swift */; };
|
||||
B5677D3F1CD3B1E400322BFC /* ICloudStoreObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5677D3C1CD3B1E400322BFC /* ICloudStoreObserver.swift */; };
|
||||
B5677D401CD3B1E400322BFC /* ICloudStoreObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5677D3C1CD3B1E400322BFC /* ICloudStoreObserver.swift */; };
|
||||
@@ -589,7 +585,6 @@
|
||||
B501FDE61CA8D20500BE22EF /* CSListObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSListObserver.swift; sourceTree = "<group>"; };
|
||||
B50392F81C478FF3009900CA /* NSManagedObject+Transaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObject+Transaction.swift"; sourceTree = "<group>"; };
|
||||
B504D0D51B02362500B2BBB1 /* CoreStore+Setup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CoreStore+Setup.swift"; sourceTree = "<group>"; };
|
||||
B519E4571C4CD2CA00E7B469 /* GCDKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GCDKit.framework; path = "../../Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/GCDKit.framework"; sourceTree = "<group>"; };
|
||||
B51BE0691B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObjectModel+Setup.swift"; sourceTree = "<group>"; };
|
||||
B51FE5AA1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CoreStore+CustomDebugStringConvertible.swift"; sourceTree = "<group>"; };
|
||||
B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSFetchedResultsController+Convenience.swift"; sourceTree = "<group>"; };
|
||||
@@ -641,16 +636,12 @@
|
||||
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; };
|
||||
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; };
|
||||
B565078F1D393087000596DA /* GCDKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GCDKit.framework; path = "../../../Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/GCDKit.framework"; sourceTree = "<group>"; };
|
||||
B56507911D3930B5000596DA /* GCDKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GCDKit.framework; path = "Carthage/Checkouts/GCDKit/build/Debug-appletvos/GCDKit.framework"; 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; };
|
||||
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; };
|
||||
B56507991D3930D1000596DA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
|
||||
B565079B1D3930D8000596DA /* GCDKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GCDKit.framework; path = "Carthage/Checkouts/GCDKit/build/Debug-watchos/GCDKit.framework"; sourceTree = "<group>"; };
|
||||
B565079D1D3930ED000596DA /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; };
|
||||
B565079F1D3930F5000596DA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
|
||||
B56507A11D393101000596DA /* GCDKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GCDKit.framework; path = Carthage/Checkouts/GCDKit/build/Debug/GCDKit.framework; sourceTree = "<group>"; };
|
||||
B5677D3C1CD3B1E400322BFC /* ICloudStoreObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ICloudStoreObserver.swift; sourceTree = "<group>"; };
|
||||
B56964D31B22FFAD0075EE4A /* DataStack+Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "DataStack+Migration.swift"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
|
||||
B56965231B356B820075EE4A /* MigrationResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MigrationResult.swift; sourceTree = "<group>"; };
|
||||
@@ -753,7 +744,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B56507901D393087000596DA /* GCDKit.framework in Frameworks */,
|
||||
B5D39A0219FD00C9000E91BB /* Foundation.framework in Frameworks */,
|
||||
2F03A54D19C5C872005002A5 /* CoreData.framework in Frameworks */,
|
||||
);
|
||||
@@ -773,7 +763,6 @@
|
||||
files = (
|
||||
B56507961D3930C1000596DA /* Foundation.framework in Frameworks */,
|
||||
B56507941D3930BC000596DA /* CoreData.framework in Frameworks */,
|
||||
B56507921D3930B5000596DA /* GCDKit.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -789,7 +778,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B56507A21D393101000596DA /* GCDKit.framework in Frameworks */,
|
||||
B56507A01D3930F5000596DA /* Foundation.framework in Frameworks */,
|
||||
B565079E1D3930ED000596DA /* CoreData.framework in Frameworks */,
|
||||
);
|
||||
@@ -807,7 +795,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B565079C1D3930D8000596DA /* GCDKit.framework in Frameworks */,
|
||||
B565079A1D3930D1000596DA /* Foundation.framework in Frameworks */,
|
||||
B56507981D3930CC000596DA /* CoreData.framework in Frameworks */,
|
||||
);
|
||||
@@ -908,17 +895,12 @@
|
||||
2F291E3119C6D4D3007AF63F /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B56507A11D393101000596DA /* GCDKit.framework */,
|
||||
B565079F1D3930F5000596DA /* Foundation.framework */,
|
||||
B565079D1D3930ED000596DA /* CoreData.framework */,
|
||||
B565079B1D3930D8000596DA /* GCDKit.framework */,
|
||||
B56507991D3930D1000596DA /* Foundation.framework */,
|
||||
B56507971D3930CC000596DA /* CoreData.framework */,
|
||||
B56507951D3930C1000596DA /* Foundation.framework */,
|
||||
B56507931D3930BC000596DA /* CoreData.framework */,
|
||||
B56507911D3930B5000596DA /* GCDKit.framework */,
|
||||
B565078F1D393087000596DA /* GCDKit.framework */,
|
||||
B519E4571C4CD2CA00E7B469 /* GCDKit.framework */,
|
||||
B5548CD71BD65AE50077652A /* CoreData.framework */,
|
||||
B56321791BD650DE006C9394 /* CoreData.framework */,
|
||||
82BA18E01C4BBE2C00A0916E /* CoreData.framework */,
|
||||
@@ -2131,8 +2113,10 @@
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
@@ -2188,8 +2172,10 @@
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
@@ -2229,6 +2215,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
@@ -2246,6 +2233,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
@@ -2295,6 +2283,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
@@ -2314,6 +2303,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
@@ -2364,17 +2354,14 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Checkouts/GCDKit/build/Debug",
|
||||
);
|
||||
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
|
||||
FRAMEWORK_VERSION = A;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
@@ -2389,7 +2376,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
@@ -2397,10 +2384,7 @@
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Checkouts/GCDKit/build/Debug",
|
||||
);
|
||||
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
|
||||
FRAMEWORK_VERSION = A;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
@@ -2450,15 +2434,13 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "";
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Checkouts/GCDKit/build/Debug-watchos",
|
||||
);
|
||||
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
@@ -2473,16 +2455,14 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Checkouts/GCDKit/build/Debug-watchos",
|
||||
);
|
||||
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
|
||||
-3
@@ -7,7 +7,4 @@
|
||||
<FileRef
|
||||
location = "group:CoreStoreDemo/CoreStoreDemo.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Carthage/Checkouts/GCDKit/GCDKit.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
B569651C1B30889A0075EE4A /* QueryingResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B569651B1B30889A0075EE4A /* QueryingResultsViewController.swift */; };
|
||||
B56965291B3582D30075EE4A /* MigrationDemo.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = B56965271B3582D30075EE4A /* MigrationDemo.xcdatamodeld */; };
|
||||
B5E599321B5240F50084BD5F /* OrganismTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E599311B5240F50084BD5F /* OrganismTableViewCell.swift */; };
|
||||
B5E89ACD1C52929C003B04A9 /* GCDKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5BDC9241C202429008147CD /* GCDKit.framework */; };
|
||||
B5E89ACE1C52929C003B04A9 /* GCDKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = B5BDC9241C202429008147CD /* GCDKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
B5E89AD01C5292A2003B04A9 /* CoreStore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5BDC9211C202429008147CD /* CoreStore.framework */; };
|
||||
B5E89AD11C5292A2003B04A9 /* CoreStore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = B5BDC9211C202429008147CD /* CoreStore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
B5EE25851B36E23C0000406B /* OrganismV1.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5EE25841B36E23C0000406B /* OrganismV1.swift */; };
|
||||
@@ -54,7 +52,6 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
B5E89ACE1C52929C003B04A9 /* GCDKit.framework in Embed Frameworks */,
|
||||
B5E89AD11C5292A2003B04A9 /* CoreStore.framework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
@@ -94,7 +91,6 @@
|
||||
B569651B1B30889A0075EE4A /* QueryingResultsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryingResultsViewController.swift; sourceTree = "<group>"; };
|
||||
B56965281B3582D30075EE4A /* MigrationDemo.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MigrationDemo.xcdatamodel; sourceTree = "<group>"; };
|
||||
B5BDC9211C202429008147CD /* CoreStore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = CoreStore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B5BDC9241C202429008147CD /* GCDKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = GCDKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B5E599311B5240F50084BD5F /* OrganismTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OrganismTableViewCell.swift; path = "CoreStoreDemo/MIgrations Demo/OrganismTableViewCell.swift"; sourceTree = SOURCE_ROOT; };
|
||||
B5EE25801B36E1B00000406B /* MigrationDemoV2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MigrationDemoV2.xcdatamodel; sourceTree = "<group>"; };
|
||||
B5EE25841B36E23C0000406B /* OrganismV1.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrganismV1.swift; sourceTree = "<group>"; };
|
||||
@@ -110,7 +106,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B5E89ACD1C52929C003B04A9 /* GCDKit.framework in Frameworks */,
|
||||
B5E89AD01C5292A2003B04A9 /* CoreStore.framework in Frameworks */,
|
||||
B52977E11B120F8A003D50A5 /* CoreLocation.framework in Frameworks */,
|
||||
B52977DF1B120F83003D50A5 /* MapKit.framework in Frameworks */,
|
||||
@@ -146,7 +141,6 @@
|
||||
children = (
|
||||
B52977E01B120F8A003D50A5 /* CoreLocation.framework */,
|
||||
B5BDC9211C202429008147CD /* CoreStore.framework */,
|
||||
B5BDC9241C202429008147CD /* GCDKit.framework */,
|
||||
B52977DE1B120F83003D50A5 /* MapKit.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
|
||||
+1
-1
@@ -271,7 +271,7 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
|
||||
return Static.timeZonesStack.queryAttributes(
|
||||
From<TimeZone>(),
|
||||
Select<NSDictionary>(
|
||||
.count("hasDaylightSavingTime", As: "numberOfCountries"),
|
||||
.count("hasDaylightSavingTime", as: "numberOfCountries"),
|
||||
"hasDaylightSavingTime"
|
||||
),
|
||||
GroupBy("hasDaylightSavingTime"),
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
import UIKit
|
||||
import CoreStore
|
||||
import GCDKit
|
||||
|
||||
|
||||
// MARK: - CustomLoggerViewController
|
||||
|
||||
@@ -11,7 +11,6 @@ import CoreLocation
|
||||
import MapKit
|
||||
import AddressBookUI
|
||||
import CoreStore
|
||||
import GCDKit
|
||||
|
||||
|
||||
private struct Static {
|
||||
|
||||
@@ -37,11 +37,11 @@ class BaseTestCase: XCTestCase {
|
||||
|
||||
@nonobjc
|
||||
@discardableResult
|
||||
func prepareStack<T>(configurations: [String?] = [nil], _ closure: @noescape (dataStack: DataStack) -> T) -> T {
|
||||
func prepareStack<T>(configurations: [String?] = [nil], _ closure: (_ dataStack: DataStack) -> T) -> T {
|
||||
|
||||
let stack = DataStack(
|
||||
modelName: "Model",
|
||||
bundle: Bundle(for: self.dynamicType)
|
||||
bundle: Bundle(for: type(of: self))
|
||||
)
|
||||
do {
|
||||
|
||||
@@ -49,9 +49,9 @@ class BaseTestCase: XCTestCase {
|
||||
|
||||
try stack.addStorageAndWait(
|
||||
SQLiteStore(
|
||||
fileURL: try SQLiteStore.defaultRootDirectory
|
||||
fileURL: SQLiteStore.defaultRootDirectory
|
||||
.appendingPathComponent(UUID().uuidString)
|
||||
.appendingPathComponent("\(self.dynamicType)_\(($0 ?? "-null-")).sqlite"),
|
||||
.appendingPathComponent("\(type(of: self))_\(($0 ?? "-null-")).sqlite"),
|
||||
configuration: $0,
|
||||
localStorageOptions: .recreateStoreOnModelMismatch
|
||||
)
|
||||
@@ -62,11 +62,11 @@ class BaseTestCase: XCTestCase {
|
||||
|
||||
XCTFail(error.coreStoreDumpString)
|
||||
}
|
||||
return closure(dataStack: stack)
|
||||
return closure(stack)
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
func expectLogger<T>(_ expectations: [TestLogger.Expectation], closure: @noescape () -> T) -> T {
|
||||
func expectLogger<T>(_ expectations: [TestLogger.Expectation], closure: () -> T) -> T {
|
||||
|
||||
CoreStore.logger = TestLogger(self.prepareLoggerExpectations(expectations))
|
||||
defer {
|
||||
@@ -89,7 +89,7 @@ class BaseTestCase: XCTestCase {
|
||||
var testExpectations: [TestLogger.Expectation: XCTestExpectation] = [:]
|
||||
for expectation in expectations {
|
||||
|
||||
testExpectations[expectation] = self.expectation(withDescription: "Logger Expectation: \(expectation)")
|
||||
testExpectations[expectation] = self.expectation(description: "Logger Expectation: \(expectation)")
|
||||
}
|
||||
return testExpectations
|
||||
}
|
||||
@@ -97,13 +97,13 @@ class BaseTestCase: XCTestCase {
|
||||
@nonobjc
|
||||
func checkExpectationsImmediately() {
|
||||
|
||||
self.waitForExpectations(withTimeout: 0, handler: nil)
|
||||
self.waitForExpectations(timeout: 0, handler: nil)
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
func waitAndCheckExpectations() {
|
||||
|
||||
self.waitForExpectations(withTimeout: 10, handler: nil)
|
||||
self.waitForExpectations(timeout: 10, handler: nil)
|
||||
}
|
||||
|
||||
// MARK: XCTestCase
|
||||
|
||||
@@ -20,8 +20,8 @@ class BaseTestDataTestCase: BaseTestCase {
|
||||
let dateFormatter: DateFormatter = {
|
||||
|
||||
let formatter = DateFormatter()
|
||||
formatter.locale = Locale(localeIdentifier: "en_US_POSIX")
|
||||
formatter.timeZone = TimeZone(name: "UTC")
|
||||
formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||
formatter.timeZone = TimeZone(identifier: "UTC")
|
||||
formatter.calendar = Calendar(identifier: Calendar.Identifier.gregorian)
|
||||
formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ssZ"
|
||||
return formatter
|
||||
@@ -42,9 +42,9 @@ class BaseTestDataTestCase: BaseTestCase {
|
||||
let object = transaction.create(Into<TestEntity1>(configuration))
|
||||
object.testEntityID = NSNumber(value: (configurationOrdinal * 100) + idIndex)
|
||||
|
||||
object.testNumber = idIndex
|
||||
object.testNumber = NSNumber(value: idIndex)
|
||||
object.testDate = self.dateFormatter.date(from: "2000-\(configurationOrdinal)-\(idIndex)T00:00:00Z")
|
||||
object.testBoolean = (idIndex % 2) == 1
|
||||
object.testBoolean = NSNumber(value: (idIndex % 2) == 1)
|
||||
object.testDecimal = NSDecimalNumber(string: "\(idIndex)")
|
||||
|
||||
let string = "\(configuration ?? "nil"):TestEntity1:\(idIndex)"
|
||||
@@ -59,9 +59,9 @@ class BaseTestDataTestCase: BaseTestCase {
|
||||
let object = transaction.create(Into<TestEntity2>(configuration))
|
||||
object.testEntityID = NSNumber(value: (configurationOrdinal * 200) + idIndex)
|
||||
|
||||
object.testNumber = idIndex
|
||||
object.testNumber = NSNumber(value: idIndex)
|
||||
object.testDate = self.dateFormatter.date(from: "2000-\(configurationOrdinal)-\(idIndex)T00:00:00Z")
|
||||
object.testBoolean = (idIndex % 2) == 1
|
||||
object.testBoolean = NSNumber(value: (idIndex % 2) == 1)
|
||||
object.testDecimal = NSDecimalNumber(string: "\(idIndex)")
|
||||
|
||||
let string = "\(configuration ?? "nil"):TestEntity2:\(idIndex)"
|
||||
@@ -70,7 +70,7 @@ class BaseTestDataTestCase: BaseTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
transaction.commitAndWait()
|
||||
_ = transaction.commitAndWait()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ final class ErrorTests: XCTestCase {
|
||||
XCTAssertEqual(error, objcError.bridgeToSwift)
|
||||
XCTAssertEqual(objcError.domain, CoreStoreErrorDomain)
|
||||
XCTAssertEqual(objcError.code, CoreStoreErrorCode.unknownError.rawValue)
|
||||
XCTAssertEqual(objcError.userInfo, userInfo)
|
||||
XCTAssertEqual(objcError.userInfo as NSDictionary, userInfo)
|
||||
|
||||
let objcError2 = objcError.bridgeToSwift.bridgeToObjectiveC
|
||||
XCTAssertEqual(error, objcError2.bridgeToSwift)
|
||||
XCTAssertEqual(objcError2.domain, CoreStoreErrorDomain)
|
||||
XCTAssertEqual(objcError2.code, CoreStoreErrorCode.unknownError.rawValue)
|
||||
XCTAssertEqual(objcError2.userInfo, userInfo)
|
||||
XCTAssertEqual(objcError2.userInfo as NSDictionary, userInfo)
|
||||
}
|
||||
|
||||
@objc
|
||||
@@ -71,13 +71,13 @@ final class ErrorTests: XCTestCase {
|
||||
XCTAssertEqual(error, objcError.bridgeToSwift)
|
||||
XCTAssertEqual(objcError.domain, CoreStoreErrorDomain)
|
||||
XCTAssertEqual(objcError.code, CoreStoreErrorCode.differentStorageExistsAtURL.rawValue)
|
||||
XCTAssertEqual(objcError.userInfo, userInfo)
|
||||
XCTAssertEqual(objcError.userInfo as NSDictionary, userInfo)
|
||||
|
||||
let objcError2 = objcError.bridgeToSwift.bridgeToObjectiveC
|
||||
XCTAssertEqual(error, objcError2.bridgeToSwift)
|
||||
XCTAssertEqual(objcError2.domain, CoreStoreErrorDomain)
|
||||
XCTAssertEqual(objcError2.code, CoreStoreErrorCode.differentStorageExistsAtURL.rawValue)
|
||||
XCTAssertEqual(objcError2.userInfo, userInfo)
|
||||
XCTAssertEqual(objcError2.userInfo as NSDictionary, userInfo)
|
||||
}
|
||||
|
||||
@objc
|
||||
@@ -85,7 +85,7 @@ final class ErrorTests: XCTestCase {
|
||||
|
||||
let dummyURL = URL(string: "file:///test1/test2.sqlite")!
|
||||
|
||||
let model = NSManagedObjectModel.fromBundle(Bundle(for: self.dynamicType), modelName: "Model")
|
||||
let model = NSManagedObjectModel.fromBundle(Bundle(for: type(of: self)), modelName: "Model")
|
||||
let version = "1.0.0"
|
||||
|
||||
let error = CoreStoreError.mappingModelNotFound(localStoreURL: dummyURL, targetModel: model, targetModelVersion: version)
|
||||
@@ -101,13 +101,13 @@ final class ErrorTests: XCTestCase {
|
||||
XCTAssertEqual(error, objcError.bridgeToSwift)
|
||||
XCTAssertEqual(objcError.domain, CoreStoreErrorDomain)
|
||||
XCTAssertEqual(objcError.code, CoreStoreErrorCode.mappingModelNotFound.rawValue)
|
||||
XCTAssertEqual(objcError.userInfo, userInfo)
|
||||
XCTAssertEqual(objcError.userInfo as NSDictionary, userInfo)
|
||||
|
||||
let objcError2 = objcError.bridgeToSwift.bridgeToObjectiveC
|
||||
XCTAssertEqual(error, objcError2.bridgeToSwift)
|
||||
XCTAssertEqual(objcError2.domain, CoreStoreErrorDomain)
|
||||
XCTAssertEqual(objcError2.code, CoreStoreErrorCode.mappingModelNotFound.rawValue)
|
||||
XCTAssertEqual(objcError2.userInfo, userInfo)
|
||||
XCTAssertEqual(objcError2.userInfo as NSDictionary, userInfo)
|
||||
}
|
||||
|
||||
@objc
|
||||
@@ -126,13 +126,13 @@ final class ErrorTests: XCTestCase {
|
||||
XCTAssertEqual(error, objcError.bridgeToSwift)
|
||||
XCTAssertEqual(objcError.domain, CoreStoreErrorDomain)
|
||||
XCTAssertEqual(objcError.code, CoreStoreErrorCode.progressiveMigrationRequired.rawValue)
|
||||
XCTAssertEqual(objcError.userInfo, userInfo)
|
||||
XCTAssertEqual(objcError.userInfo as NSDictionary, userInfo)
|
||||
|
||||
let objcError2 = objcError.bridgeToSwift.bridgeToObjectiveC
|
||||
XCTAssertEqual(error, objcError2.bridgeToSwift)
|
||||
XCTAssertEqual(objcError2.domain, CoreStoreErrorDomain)
|
||||
XCTAssertEqual(objcError2.code, CoreStoreErrorCode.progressiveMigrationRequired.rawValue)
|
||||
XCTAssertEqual(objcError2.userInfo, userInfo)
|
||||
XCTAssertEqual(objcError2.userInfo as NSDictionary, userInfo)
|
||||
}
|
||||
|
||||
@objc
|
||||
@@ -158,12 +158,12 @@ final class ErrorTests: XCTestCase {
|
||||
XCTAssertEqual(error, objcError.bridgeToSwift)
|
||||
XCTAssertEqual(objcError.domain, CoreStoreErrorDomain)
|
||||
XCTAssertEqual(objcError.code, CoreStoreErrorCode.internalError.rawValue)
|
||||
XCTAssertEqual(objcError.userInfo, userInfo)
|
||||
XCTAssertEqual(objcError.userInfo as NSDictionary, userInfo)
|
||||
|
||||
let objcError2 = objcError.bridgeToSwift.bridgeToObjectiveC
|
||||
XCTAssertEqual(error, objcError2.bridgeToSwift)
|
||||
XCTAssertEqual(objcError2.domain, CoreStoreErrorDomain)
|
||||
XCTAssertEqual(objcError2.code, CoreStoreErrorCode.internalError.rawValue)
|
||||
XCTAssertEqual(objcError2.userInfo, userInfo)
|
||||
XCTAssertEqual(objcError2.userInfo as NSDictionary, userInfo)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let fetchExpectation = self.expectation(withDescription: "fetch")
|
||||
let fetchExpectation = self.expectation(description: "fetch")
|
||||
|
||||
var existing1: TestEntity1?
|
||||
stack.beginSynchronous { (transaction) in
|
||||
@@ -88,7 +88,7 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let fetchExpectation = self.expectation(withDescription: "fetch")
|
||||
let fetchExpectation = self.expectation(description: "fetch")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
let existing1 = transaction.fetchExisting(object)
|
||||
@@ -162,7 +162,7 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let fetchExpectation = self.expectation(withDescription: "fetch")
|
||||
let fetchExpectation = self.expectation(description: "fetch")
|
||||
|
||||
var existing1 = [TestEntity1]()
|
||||
stack.beginSynchronous { (transaction) in
|
||||
@@ -191,7 +191,7 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let fetchExpectation = self.expectation(withDescription: "fetch")
|
||||
let fetchExpectation = self.expectation(description: "fetch")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
let existing1 = transaction.fetchExisting(objects)
|
||||
|
||||
@@ -72,7 +72,7 @@ class ImportTests: BaseTestDataTestCase {
|
||||
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
let errorExpectation = self.expectation(withDescription: "error")
|
||||
let errorExpectation = self.expectation(description: "error")
|
||||
do {
|
||||
|
||||
let _ = try transaction.importObject(
|
||||
@@ -215,8 +215,8 @@ class ImportTests: BaseTestDataTestCase {
|
||||
XCTAssertEqual(object.testNumber, dictionary["testNumber"] as? NSNumber)
|
||||
XCTAssertEqual(object.testDecimal, dictionary["testDecimal"] as? NSDecimalNumber)
|
||||
XCTAssertEqual(object.testString, dictionary["testString"] as? String)
|
||||
XCTAssertEqual(object.testData, dictionary["testData"] as? NSData)
|
||||
XCTAssertEqual(object.testDate, dictionary["testDate"] as? NSDate)
|
||||
XCTAssertEqual(object.testData, dictionary["testData"] as? Data)
|
||||
XCTAssertEqual(object.testDate, dictionary["testDate"] as? Date)
|
||||
}
|
||||
catch {
|
||||
|
||||
@@ -234,7 +234,7 @@ class ImportTests: BaseTestDataTestCase {
|
||||
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
let errorExpectation = self.expectation(withDescription: "error")
|
||||
let errorExpectation = self.expectation(description: "error")
|
||||
do {
|
||||
|
||||
let sourceArray: [TestEntity1.ImportSource] = [
|
||||
@@ -331,8 +331,8 @@ class ImportTests: BaseTestDataTestCase {
|
||||
XCTAssertEqual(object.testNumber, dictionary["testNumber"] as? NSNumber)
|
||||
XCTAssertEqual(object.testDecimal, dictionary["testDecimal"] as? NSDecimalNumber)
|
||||
XCTAssertEqual(object.testString, dictionary["testString"] as? String)
|
||||
XCTAssertEqual(object.testData, dictionary["testData"] as? NSData)
|
||||
XCTAssertEqual(object.testDate, dictionary["testDate"] as? NSDate)
|
||||
XCTAssertEqual(object.testData, dictionary["testData"] as? Data)
|
||||
XCTAssertEqual(object.testDate, dictionary["testDate"] as? Date)
|
||||
}
|
||||
}
|
||||
catch {
|
||||
@@ -425,7 +425,7 @@ class ImportTests: BaseTestDataTestCase {
|
||||
|
||||
do {
|
||||
|
||||
let errorExpectation = self.expectation(withDescription: "error")
|
||||
let errorExpectation = self.expectation(description: "error")
|
||||
do {
|
||||
|
||||
let _ = try transaction.importUniqueObject(
|
||||
@@ -466,7 +466,7 @@ class ImportTests: BaseTestDataTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let errorExpectation = self.expectation(withDescription: "error")
|
||||
let errorExpectation = self.expectation(description: "error")
|
||||
do {
|
||||
|
||||
let _ = try transaction.importUniqueObject(
|
||||
@@ -639,8 +639,8 @@ class ImportTests: BaseTestDataTestCase {
|
||||
XCTAssertEqual(object.testNumber, dictionary["testNumber"] as? NSNumber)
|
||||
XCTAssertEqual(object.testDecimal, dictionary["testDecimal"] as? NSDecimalNumber)
|
||||
XCTAssertEqual(object.testString, dictionary["testString"] as? String)
|
||||
XCTAssertEqual(object.testData, dictionary["testData"] as? NSData)
|
||||
XCTAssertEqual(object.testDate, dictionary["testDate"] as? NSDate)
|
||||
XCTAssertEqual(object.testData, dictionary["testData"] as? Data)
|
||||
XCTAssertEqual(object.testDate, dictionary["testDate"] as? Date)
|
||||
}
|
||||
catch {
|
||||
|
||||
@@ -660,7 +660,7 @@ class ImportTests: BaseTestDataTestCase {
|
||||
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
let errorExpectation = self.expectation(withDescription: "error")
|
||||
let errorExpectation = self.expectation(description: "error")
|
||||
do {
|
||||
|
||||
let sourceArray: [TestEntity1.ImportSource] = [
|
||||
@@ -707,7 +707,7 @@ class ImportTests: BaseTestDataTestCase {
|
||||
}
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
let errorExpectation = self.expectation(withDescription: "error")
|
||||
let errorExpectation = self.expectation(description: "error")
|
||||
do {
|
||||
|
||||
let sourceArray: [TestEntity1.ImportSource] = [
|
||||
@@ -760,7 +760,7 @@ class ImportTests: BaseTestDataTestCase {
|
||||
}
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
let errorExpectation = self.expectation(withDescription: "error")
|
||||
let errorExpectation = self.expectation(description: "error")
|
||||
do {
|
||||
|
||||
let sourceArray: [TestEntity1.ImportSource] = [
|
||||
@@ -860,8 +860,8 @@ class ImportTests: BaseTestDataTestCase {
|
||||
XCTAssertEqual(object.testNumber, dictionary["testNumber"] as? NSNumber)
|
||||
XCTAssertEqual(object.testDecimal, dictionary["testDecimal"] as? NSDecimalNumber)
|
||||
XCTAssertEqual(object.testString, dictionary["testString"] as? String)
|
||||
XCTAssertEqual(object.testData, dictionary["testData"] as? NSData)
|
||||
XCTAssertEqual(object.testDate, dictionary["testDate"] as? NSDate)
|
||||
XCTAssertEqual(object.testData, dictionary["testData"] as? Data)
|
||||
XCTAssertEqual(object.testDate, dictionary["testDate"] as? Date)
|
||||
}
|
||||
let existingObjects = transaction.fetchAll(From<TestEntity1>(), Where("testEntityID", isEqualTo: 105))
|
||||
XCTAssertNotNil(existingObjects)
|
||||
@@ -883,17 +883,17 @@ class ImportTests: BaseTestDataTestCase {
|
||||
|
||||
// MARK: - TestInsertError
|
||||
|
||||
private struct TestInsertError: ErrorProtocol {}
|
||||
private struct TestInsertError: Error {}
|
||||
|
||||
|
||||
// MARK: - TestUpdateError
|
||||
|
||||
private struct TestUpdateError: ErrorProtocol {}
|
||||
private struct TestUpdateError: Error {}
|
||||
|
||||
|
||||
// MARK: - TestIDError
|
||||
|
||||
private struct TestIDError: ErrorProtocol {}
|
||||
private struct TestIDError: Error {}
|
||||
|
||||
|
||||
// MARK: - TestEntity1
|
||||
@@ -902,14 +902,14 @@ extension TestEntity1: ImportableUniqueObject {
|
||||
|
||||
// MARK: ImportableObject
|
||||
|
||||
typealias ImportSource = [String: AnyObject]
|
||||
typealias ImportSource = [String: Any]
|
||||
|
||||
static func shouldInsertFromImportSource(_ source: [String: AnyObject], inTransaction transaction: BaseDataTransaction) -> Bool {
|
||||
static func shouldInsertFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) -> Bool {
|
||||
|
||||
return source["skip_insert"] == nil
|
||||
}
|
||||
|
||||
func didInsertFromImportSource(_ source: [String: AnyObject], inTransaction transaction: BaseDataTransaction) throws {
|
||||
func didInsertFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) throws {
|
||||
|
||||
if let _ = source["throw_on_insert"] {
|
||||
|
||||
@@ -951,12 +951,12 @@ extension TestEntity1: ImportableUniqueObject {
|
||||
}
|
||||
}
|
||||
|
||||
static func shouldUpdateFromImportSource(_ source: [String: AnyObject], inTransaction transaction: BaseDataTransaction) -> Bool {
|
||||
static func shouldUpdateFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) -> Bool {
|
||||
|
||||
return source["skip_update"] == nil
|
||||
}
|
||||
|
||||
static func uniqueIDFromImportSource(_ source: [String: AnyObject], inTransaction transaction: BaseDataTransaction) throws -> NSNumber? {
|
||||
static func uniqueIDFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) throws -> NSNumber? {
|
||||
|
||||
if let _ = source["throw_on_id"] {
|
||||
|
||||
@@ -965,7 +965,7 @@ extension TestEntity1: ImportableUniqueObject {
|
||||
return source["testEntityID"] as? NSNumber
|
||||
}
|
||||
|
||||
func updateFromImportSource(_ source: [String: AnyObject], inTransaction transaction: BaseDataTransaction) throws {
|
||||
func updateFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) throws {
|
||||
|
||||
if let _ = source["throw_on_update"] {
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
handler: { (note) -> Bool in
|
||||
|
||||
XCTAssertEqual(events, 0)
|
||||
XCTAssertEqual(((note as NSNotification).userInfo ?? [:]), NSDictionary())
|
||||
XCTAssertEqual((note.userInfo as NSDictionary?) ?? [:], NSDictionary())
|
||||
defer {
|
||||
|
||||
events += 1
|
||||
@@ -75,7 +75,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
|
||||
XCTAssertEqual(events, 1)
|
||||
XCTAssertEqual(
|
||||
((note as NSNotification).userInfo ?? [:]),
|
||||
((note.userInfo as NSDictionary?) ?? [:]),
|
||||
[
|
||||
"sectionInfo": monitor.sectionInfoAtIndex(0),
|
||||
"sectionIndex": 0
|
||||
@@ -95,10 +95,10 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
|
||||
XCTAssertEqual(events, 2)
|
||||
|
||||
let userInfo = (note as NSNotification).userInfo
|
||||
let userInfo = note.userInfo
|
||||
XCTAssertNotNil(userInfo)
|
||||
XCTAssertEqual(
|
||||
Set(((userInfo as? [String: AnyObject]) ?? [:]).keys),
|
||||
Set(userInfo?.keys.map({ $0 as! String }) ?? []),
|
||||
["indexPath", "object"]
|
||||
)
|
||||
|
||||
@@ -125,7 +125,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
object: observer,
|
||||
handler: { (note) -> Bool in
|
||||
|
||||
XCTAssertEqual(((note as NSNotification).userInfo ?? [:]), NSDictionary())
|
||||
XCTAssertEqual((note.userInfo as NSDictionary?) ?? [:], NSDictionary())
|
||||
defer {
|
||||
|
||||
events += 1
|
||||
@@ -133,7 +133,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
return events == 3
|
||||
}
|
||||
)
|
||||
let saveExpectation = self.expectation(withDescription: "save")
|
||||
let saveExpectation = self.expectation(description: "save")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
let object = transaction.create(Into<TestEntity1>())
|
||||
@@ -191,7 +191,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
handler: { (note) -> Bool in
|
||||
|
||||
XCTAssertEqual(events, 0)
|
||||
XCTAssertEqual(((note as NSNotification).userInfo ?? [:]), NSDictionary())
|
||||
XCTAssertEqual((note.userInfo as NSDictionary?) ?? [:], NSDictionary())
|
||||
defer {
|
||||
|
||||
events += 1
|
||||
@@ -208,10 +208,10 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
|
||||
XCTAssert(events == 1 || events == 2)
|
||||
|
||||
let userInfo = (note as NSNotification).userInfo
|
||||
let userInfo = note.userInfo
|
||||
XCTAssertNotNil(userInfo)
|
||||
XCTAssertEqual(
|
||||
Set(((userInfo as? [String: AnyObject]) ?? [:]).keys),
|
||||
Set(userInfo?.keys.map({ $0 as! String }) ?? []),
|
||||
["indexPath", "object"]
|
||||
)
|
||||
|
||||
@@ -259,7 +259,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
handler: { (note) -> Bool in
|
||||
|
||||
XCTAssertEqual(events, 3)
|
||||
XCTAssertEqual(((note as NSNotification).userInfo ?? [:]), NSDictionary())
|
||||
XCTAssertEqual((note.userInfo as NSDictionary?) ?? [:], NSDictionary())
|
||||
defer {
|
||||
|
||||
events += 1
|
||||
@@ -267,7 +267,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
return events == 3
|
||||
}
|
||||
)
|
||||
let saveExpectation = self.expectation(withDescription: "save")
|
||||
let saveExpectation = self.expectation(description: "save")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
if let object = transaction.fetchOne(
|
||||
@@ -338,7 +338,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
handler: { (note) -> Bool in
|
||||
|
||||
XCTAssertEqual(events, 0)
|
||||
XCTAssertEqual(((note as NSNotification).userInfo ?? [:]), NSDictionary())
|
||||
XCTAssertEqual((note.userInfo as NSDictionary?) ?? [:], NSDictionary())
|
||||
defer {
|
||||
|
||||
events += 1
|
||||
@@ -353,10 +353,10 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
|
||||
XCTAssertEqual(events, 1)
|
||||
|
||||
let userInfo = (note as NSNotification).userInfo
|
||||
let userInfo = note.userInfo
|
||||
XCTAssertNotNil(userInfo)
|
||||
XCTAssertEqual(
|
||||
Set(((userInfo as? [String: AnyObject]) ?? [:]).keys),
|
||||
Set(userInfo?.keys.map({ $0 as! String }) ?? []),
|
||||
["fromIndexPath", "toIndexPath", "object"]
|
||||
)
|
||||
|
||||
@@ -385,7 +385,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
handler: { (note) -> Bool in
|
||||
|
||||
XCTAssertEqual(events, 2)
|
||||
XCTAssertEqual(((note as NSNotification).userInfo ?? [:]), NSDictionary())
|
||||
XCTAssertEqual((note.userInfo as NSDictionary?) ?? [:], NSDictionary())
|
||||
defer {
|
||||
|
||||
events += 1
|
||||
@@ -393,7 +393,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
return events == 2
|
||||
}
|
||||
)
|
||||
let saveExpectation = self.expectation(withDescription: "save")
|
||||
let saveExpectation = self.expectation(description: "save")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
if let object = transaction.fetchOne(
|
||||
@@ -446,7 +446,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
handler: { (note) -> Bool in
|
||||
|
||||
XCTAssertEqual(events, 0)
|
||||
XCTAssertEqual(((note as NSNotification).userInfo ?? [:]), NSDictionary())
|
||||
XCTAssertEqual((note.userInfo as NSDictionary?) ?? [:], NSDictionary())
|
||||
defer {
|
||||
|
||||
events += 1
|
||||
@@ -463,10 +463,10 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
|
||||
XCTAssert(events == 1 || events == 2)
|
||||
|
||||
let userInfo = (note as NSNotification).userInfo
|
||||
let userInfo = note.userInfo
|
||||
XCTAssertNotNil(userInfo)
|
||||
XCTAssertEqual(
|
||||
Set(((userInfo as? [String: AnyObject]) ?? [:]).keys),
|
||||
Set(userInfo?.keys.map({ $0 as! String }) ?? []),
|
||||
["indexPath", "object"]
|
||||
)
|
||||
|
||||
@@ -493,14 +493,14 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
|
||||
XCTAssertEqual(events, 3)
|
||||
|
||||
let userInfo = (note as NSNotification).userInfo
|
||||
let userInfo = note.userInfo
|
||||
XCTAssertNotNil(userInfo)
|
||||
XCTAssertEqual(
|
||||
Set(((userInfo as? [String: AnyObject]) ?? [:]).keys),
|
||||
Set(userInfo?.keys.map({ $0 as! String }) ?? []),
|
||||
["sectionInfo", "sectionIndex"]
|
||||
)
|
||||
|
||||
let sectionInfo = userInfo?["sectionInfo"]
|
||||
let sectionInfo = userInfo?["sectionInfo"] as? NSFetchedResultsSectionInfo
|
||||
XCTAssertNotNil(sectionInfo)
|
||||
XCTAssertEqual(sectionInfo?.name, "0")
|
||||
|
||||
@@ -520,7 +520,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
handler: { (note) -> Bool in
|
||||
|
||||
XCTAssertEqual(events, 4)
|
||||
XCTAssertEqual(((note as NSNotification).userInfo ?? [:]), NSDictionary())
|
||||
XCTAssertEqual((note.userInfo as NSDictionary?) ?? [:], NSDictionary())
|
||||
defer {
|
||||
|
||||
events += 1
|
||||
@@ -528,7 +528,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
return events == 4
|
||||
}
|
||||
)
|
||||
let saveExpectation = self.expectation(withDescription: "save")
|
||||
let saveExpectation = self.expectation(description: "save")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
transaction.deleteAll(
|
||||
|
||||
@@ -65,7 +65,7 @@ class ObjectObserverTests: BaseTestDataTestCase {
|
||||
|
||||
XCTAssertEqual(events, 0)
|
||||
XCTAssertEqual(
|
||||
((note as NSNotification).userInfo ?? [:]),
|
||||
((note.userInfo as NSDictionary?) ?? [:]),
|
||||
["object": object] as NSDictionary
|
||||
)
|
||||
defer {
|
||||
@@ -82,7 +82,7 @@ class ObjectObserverTests: BaseTestDataTestCase {
|
||||
|
||||
XCTAssertEqual(events, 1)
|
||||
XCTAssertEqual(
|
||||
((note as NSNotification).userInfo ?? [:]),
|
||||
((note.userInfo as NSDictionary?) ?? [:]),
|
||||
[
|
||||
"object": object,
|
||||
"changedPersistentKeys": Set(
|
||||
@@ -104,7 +104,7 @@ class ObjectObserverTests: BaseTestDataTestCase {
|
||||
return events == 1
|
||||
}
|
||||
)
|
||||
let saveExpectation = self.expectation(withDescription: "save")
|
||||
let saveExpectation = self.expectation(description: "save")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
guard let object = transaction.edit(object) else {
|
||||
@@ -162,7 +162,7 @@ class ObjectObserverTests: BaseTestDataTestCase {
|
||||
|
||||
XCTAssertEqual(events, 0)
|
||||
XCTAssertEqual(
|
||||
((note as NSNotification).userInfo ?? [:]),
|
||||
((note.userInfo as NSDictionary?) ?? [:]),
|
||||
["object": object] as NSDictionary
|
||||
)
|
||||
defer {
|
||||
@@ -172,7 +172,7 @@ class ObjectObserverTests: BaseTestDataTestCase {
|
||||
return events == 0
|
||||
}
|
||||
)
|
||||
let saveExpectation = self.expectation(withDescription: "save")
|
||||
let saveExpectation = self.expectation(description: "save")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
guard let object = transaction.edit(object) else {
|
||||
|
||||
@@ -39,27 +39,27 @@ final class OrderByTests: XCTestCase {
|
||||
do {
|
||||
|
||||
let orderBy = OrderBy()
|
||||
XCTAssertEqual(orderBy, OrderBy([SortDescriptor]()))
|
||||
XCTAssertNotEqual(orderBy, OrderBy(SortDescriptor(key: "key", ascending: false)))
|
||||
XCTAssertEqual(orderBy, OrderBy([NSSortDescriptor]()))
|
||||
XCTAssertNotEqual(orderBy, OrderBy(NSSortDescriptor(key: "key", ascending: false)))
|
||||
XCTAssertTrue(orderBy.sortDescriptors.isEmpty)
|
||||
}
|
||||
do {
|
||||
|
||||
let sortDescriptor = SortDescriptor(key: "key1", ascending: true)
|
||||
let sortDescriptor = NSSortDescriptor(key: "key1", ascending: true)
|
||||
let orderBy = OrderBy(sortDescriptor)
|
||||
XCTAssertEqual(orderBy, OrderBy(sortDescriptor))
|
||||
XCTAssertEqual(orderBy, OrderBy(.ascending("key1")))
|
||||
XCTAssertNotEqual(orderBy, OrderBy(.ascending("key2")))
|
||||
XCTAssertNotEqual(orderBy, OrderBy(.descending("key1")))
|
||||
XCTAssertNotEqual(orderBy, OrderBy(SortDescriptor(key: "key1", ascending: false)))
|
||||
XCTAssertNotEqual(orderBy, OrderBy(NSSortDescriptor(key: "key1", ascending: false)))
|
||||
XCTAssertEqual(orderBy, OrderBy([sortDescriptor]))
|
||||
XCTAssertEqual(orderBy.sortDescriptors, [sortDescriptor])
|
||||
}
|
||||
do {
|
||||
|
||||
let sortDescriptors = [
|
||||
SortDescriptor(key: "key1", ascending: true),
|
||||
SortDescriptor(key: "key2", ascending: false)
|
||||
NSSortDescriptor(key: "key1", ascending: true),
|
||||
NSSortDescriptor(key: "key2", ascending: false)
|
||||
]
|
||||
let orderBy = OrderBy(sortDescriptors)
|
||||
XCTAssertEqual(orderBy, OrderBy(sortDescriptors))
|
||||
@@ -68,8 +68,8 @@ final class OrderByTests: XCTestCase {
|
||||
orderBy,
|
||||
OrderBy(
|
||||
[
|
||||
SortDescriptor(key: "key1", ascending: false),
|
||||
SortDescriptor(key: "key2", ascending: false)
|
||||
NSSortDescriptor(key: "key1", ascending: false),
|
||||
NSSortDescriptor(key: "key2", ascending: false)
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -80,7 +80,7 @@ final class OrderByTests: XCTestCase {
|
||||
do {
|
||||
|
||||
let orderBy = OrderBy(.ascending("key1"))
|
||||
let sortDescriptor = SortDescriptor(key: "key1", ascending: true)
|
||||
let sortDescriptor = NSSortDescriptor(key: "key1", ascending: true)
|
||||
XCTAssertEqual(orderBy, OrderBy(sortDescriptor))
|
||||
XCTAssertEqual(orderBy, OrderBy(.ascending("key1")))
|
||||
XCTAssertNotEqual(orderBy, OrderBy(.descending("key1")))
|
||||
@@ -92,8 +92,8 @@ final class OrderByTests: XCTestCase {
|
||||
|
||||
let orderBy = OrderBy(.ascending("key1"), .descending("key2"))
|
||||
let sortDescriptors = [
|
||||
SortDescriptor(key: "key1", ascending: true),
|
||||
SortDescriptor(key: "key2", ascending: false)
|
||||
NSSortDescriptor(key: "key1", ascending: true),
|
||||
NSSortDescriptor(key: "key2", ascending: false)
|
||||
]
|
||||
XCTAssertEqual(orderBy, OrderBy(sortDescriptors))
|
||||
XCTAssertEqual(orderBy, OrderBy(.ascending("key1"), .descending("key2")))
|
||||
@@ -101,8 +101,8 @@ final class OrderByTests: XCTestCase {
|
||||
orderBy,
|
||||
OrderBy(
|
||||
[
|
||||
SortDescriptor(key: "key1", ascending: false),
|
||||
SortDescriptor(key: "key2", ascending: false)
|
||||
NSSortDescriptor(key: "key1", ascending: false),
|
||||
NSSortDescriptor(key: "key2", ascending: false)
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -115,8 +115,8 @@ final class OrderByTests: XCTestCase {
|
||||
let sortKeys: [SortKey] = [.ascending("key1"), .descending("key2")]
|
||||
let orderBy = OrderBy(sortKeys)
|
||||
let sortDescriptors = [
|
||||
SortDescriptor(key: "key1", ascending: true),
|
||||
SortDescriptor(key: "key2", ascending: false)
|
||||
NSSortDescriptor(key: "key1", ascending: true),
|
||||
NSSortDescriptor(key: "key2", ascending: false)
|
||||
]
|
||||
XCTAssertEqual(orderBy, OrderBy(sortDescriptors))
|
||||
XCTAssertEqual(orderBy, OrderBy(.ascending("key1"), .descending("key2")))
|
||||
@@ -124,8 +124,8 @@ final class OrderByTests: XCTestCase {
|
||||
orderBy,
|
||||
OrderBy(
|
||||
[
|
||||
SortDescriptor(key: "key1", ascending: false),
|
||||
SortDescriptor(key: "key2", ascending: false)
|
||||
NSSortDescriptor(key: "key1", ascending: false),
|
||||
NSSortDescriptor(key: "key2", ascending: false)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
@@ -173,7 +173,7 @@ class QueryTests: BaseTestDataTestCase {
|
||||
queryClauses
|
||||
)
|
||||
XCTAssertNotNil(value)
|
||||
XCTAssertEqual(value, ("nil:TestEntity1:1" as NSString).data(using: String.Encoding.utf8.rawValue))
|
||||
XCTAssertEqual(value as Data?, "nil:TestEntity1:1".data(using: .utf8))
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -183,7 +183,7 @@ class QueryTests: BaseTestDataTestCase {
|
||||
queryClauses
|
||||
)
|
||||
XCTAssertNotNil(value)
|
||||
XCTAssertEqual(value, self.dateFormatter.date(from: "2000-01-01T00:00:00Z"))
|
||||
XCTAssertEqual(value as Date?, self.dateFormatter.date(from: "2000-01-01T00:00:00Z"))
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -657,7 +657,7 @@ class QueryTests: BaseTestDataTestCase {
|
||||
queryClauses
|
||||
)
|
||||
XCTAssertNotNil(value)
|
||||
XCTAssertEqual(value, ("nil:TestEntity1:5" as NSString).data(using: String.Encoding.utf8.rawValue))
|
||||
XCTAssertEqual(value as Data?, "nil:TestEntity1:5".data(using: .utf8))
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -667,7 +667,7 @@ class QueryTests: BaseTestDataTestCase {
|
||||
queryClauses
|
||||
)
|
||||
XCTAssertNotNil(value)
|
||||
XCTAssertEqual(value, self.dateFormatter.date(from: "2000-01-05T00:00:00Z"))
|
||||
XCTAssertEqual(value as Date?, self.dateFormatter.date(from: "2000-01-05T00:00:00Z"))
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -821,7 +821,7 @@ class QueryTests: BaseTestDataTestCase {
|
||||
queryClauses
|
||||
)
|
||||
XCTAssertNotNil(value)
|
||||
XCTAssertEqual(value, ("nil:TestEntity1:2" as NSString).data(using: String.Encoding.utf8.rawValue))
|
||||
XCTAssertEqual(value as Data?, "nil:TestEntity1:2".data(using: .utf8))
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -831,7 +831,7 @@ class QueryTests: BaseTestDataTestCase {
|
||||
queryClauses
|
||||
)
|
||||
XCTAssertNotNil(value)
|
||||
XCTAssertEqual(value, self.dateFormatter.date(from: "2000-01-02T00:00:00Z"))
|
||||
XCTAssertEqual(value as Date?, self.dateFormatter.date(from: "2000-01-02T00:00:00Z"))
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -1170,7 +1170,7 @@ class QueryTests: BaseTestDataTestCase {
|
||||
]
|
||||
do {
|
||||
|
||||
let values = stack.queryAttributes(
|
||||
let values: [NSDictionary]? = stack.queryAttributes(
|
||||
from,
|
||||
Select(
|
||||
"testBoolean",
|
||||
@@ -1203,7 +1203,7 @@ class QueryTests: BaseTestDataTestCase {
|
||||
"testData": ("nil:TestEntity1:5" as NSString).data(using: String.Encoding.utf8.rawValue)!,
|
||||
"testDate": self.dateFormatter.date(from: "2000-01-05T00:00:00Z")!
|
||||
]
|
||||
]
|
||||
] as [NSDictionary]
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1221,7 +1221,7 @@ class QueryTests: BaseTestDataTestCase {
|
||||
let queryClauses: [QueryClause] = []
|
||||
do {
|
||||
|
||||
let values = stack.queryAttributes(
|
||||
let values: [NSDictionary]? = stack.queryAttributes(
|
||||
from,
|
||||
Select(
|
||||
.sum("testBoolean"),
|
||||
@@ -1243,19 +1243,19 @@ class QueryTests: BaseTestDataTestCase {
|
||||
"min(testNumber)": 1,
|
||||
"average(testDecimal)": 3,
|
||||
]
|
||||
]
|
||||
] as [NSDictionary]
|
||||
)
|
||||
}
|
||||
do {
|
||||
|
||||
let values = stack.queryAttributes(
|
||||
let values: [NSDictionary]? = stack.queryAttributes(
|
||||
from,
|
||||
Select(
|
||||
.sum("testBoolean", As: "testSum"),
|
||||
.count("testNumber", As: "testCount"),
|
||||
.maximum("testNumber", As: "testMaximum"),
|
||||
.minimum("testNumber", As: "testMinimum"),
|
||||
.average("testDecimal", As: "testAverage")
|
||||
.sum("testBoolean", as: "testSum"),
|
||||
.count("testNumber", as: "testCount"),
|
||||
.maximum("testNumber", as: "testMaximum"),
|
||||
.minimum("testNumber", as: "testMinimum"),
|
||||
.average("testDecimal", as: "testAverage")
|
||||
),
|
||||
queryClauses
|
||||
)
|
||||
@@ -1270,7 +1270,7 @@ class QueryTests: BaseTestDataTestCase {
|
||||
"testMinimum": 1,
|
||||
"testAverage": 3,
|
||||
]
|
||||
]
|
||||
] as [NSDictionary]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,14 +42,14 @@ final class SectionByTests: XCTestCase {
|
||||
|
||||
let sectionBy = SectionBy("key")
|
||||
XCTAssertEqual(sectionBy.sectionKeyPath, "key")
|
||||
XCTAssertEqual(sectionBy.sectionIndexTransformer(sectionName: "key"), "key")
|
||||
XCTAssertEqual(sectionBy.sectionIndexTransformer("key"), "key")
|
||||
}
|
||||
do {
|
||||
|
||||
let sectionBy = SectionBy("key") { $0.flatMap { "\($0):suffix" } }
|
||||
XCTAssertEqual(sectionBy.sectionKeyPath, "key")
|
||||
XCTAssertEqual(sectionBy.sectionIndexTransformer(sectionName: "key"), "key:suffix")
|
||||
XCTAssertNil(sectionBy.sectionIndexTransformer(sectionName: nil))
|
||||
XCTAssertEqual(sectionBy.sectionIndexTransformer("key"), "key:suffix")
|
||||
XCTAssertNil(sectionBy.sectionIndexTransformer(nil))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ final class SelectTests: XCTestCase {
|
||||
|
||||
let term = SelectTerm.average("attribute")
|
||||
XCTAssertEqual(term, SelectTerm.average("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute", As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute", as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.count("attribute"))
|
||||
@@ -106,9 +106,9 @@ final class SelectTests: XCTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let term = SelectTerm.average("attribute", As: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.average("attribute", As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute", As: "alias2"))
|
||||
let term = SelectTerm.average("attribute", as: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.average("attribute", as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute", as: "alias2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.count("attribute"))
|
||||
@@ -137,7 +137,7 @@ final class SelectTests: XCTestCase {
|
||||
|
||||
let term = SelectTerm.count("attribute")
|
||||
XCTAssertEqual(term, SelectTerm.count("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.count("attribute", As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.count("attribute", as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.count("attribute2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute"))
|
||||
@@ -159,9 +159,9 @@ final class SelectTests: XCTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let term = SelectTerm.count("attribute", As: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.count("attribute", As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.count("attribute", As: "alias2"))
|
||||
let term = SelectTerm.count("attribute", as: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.count("attribute", as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.count("attribute", as: "alias2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.count("attribute2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute"))
|
||||
@@ -190,7 +190,7 @@ final class SelectTests: XCTestCase {
|
||||
|
||||
let term = SelectTerm.maximum("attribute")
|
||||
XCTAssertEqual(term, SelectTerm.maximum("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.maximum("attribute", As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.maximum("attribute", as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.maximum("attribute2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute"))
|
||||
@@ -212,9 +212,9 @@ final class SelectTests: XCTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let term = SelectTerm.maximum("attribute", As: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.maximum("attribute", As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.maximum("attribute", As: "alias2"))
|
||||
let term = SelectTerm.maximum("attribute", as: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.maximum("attribute", as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.maximum("attribute", as: "alias2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.maximum("attribute2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute"))
|
||||
@@ -243,7 +243,7 @@ final class SelectTests: XCTestCase {
|
||||
|
||||
let term = SelectTerm.minimum("attribute")
|
||||
XCTAssertEqual(term, SelectTerm.minimum("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.minimum("attribute", As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.minimum("attribute", as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.minimum("attribute2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute"))
|
||||
@@ -265,9 +265,9 @@ final class SelectTests: XCTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let term = SelectTerm.minimum("attribute", As: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.minimum("attribute", As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.minimum("attribute", As: "alias2"))
|
||||
let term = SelectTerm.minimum("attribute", as: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.minimum("attribute", as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.minimum("attribute", as: "alias2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.minimum("attribute2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute"))
|
||||
@@ -296,7 +296,7 @@ final class SelectTests: XCTestCase {
|
||||
|
||||
let term = SelectTerm.sum("attribute")
|
||||
XCTAssertEqual(term, SelectTerm.sum("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.sum("attribute", As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.sum("attribute", as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.sum("attribute2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute"))
|
||||
@@ -318,9 +318,9 @@ final class SelectTests: XCTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let term = SelectTerm.sum("attribute", As: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.sum("attribute", As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.sum("attribute", As: "alias2"))
|
||||
let term = SelectTerm.sum("attribute", as: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.sum("attribute", as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.sum("attribute", as: "alias2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.sum("attribute2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute"))
|
||||
@@ -349,7 +349,7 @@ final class SelectTests: XCTestCase {
|
||||
|
||||
let term = SelectTerm.objectID()
|
||||
XCTAssertEqual(term, SelectTerm.objectID())
|
||||
XCTAssertNotEqual(term, SelectTerm.objectID(As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.objectID(as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.count("attribute"))
|
||||
@@ -368,9 +368,9 @@ final class SelectTests: XCTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let term = SelectTerm.objectID(As: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.objectID(As: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.objectID(As: "alias2"))
|
||||
let term = SelectTerm.objectID(as: "alias")
|
||||
XCTAssertEqual(term, SelectTerm.objectID(as: "alias"))
|
||||
XCTAssertNotEqual(term, SelectTerm.objectID(as: "alias2"))
|
||||
XCTAssertNotEqual(term, SelectTerm.objectID())
|
||||
XCTAssertNotEqual(term, SelectTerm.attribute("attribute"))
|
||||
XCTAssertNotEqual(term, SelectTerm.average("attribute"))
|
||||
|
||||
@@ -36,7 +36,7 @@ class SetupTests: BaseTestCase {
|
||||
|
||||
do {
|
||||
|
||||
let model = NSManagedObjectModel.mergedModel(from: [Bundle(for: self.dynamicType)])!
|
||||
let model = NSManagedObjectModel.mergedModel(from: [Bundle(for: type(of: self))])!
|
||||
|
||||
let stack = DataStack(model: model, migrationChain: nil)
|
||||
XCTAssertEqual(stack.coordinator.managedObjectModel, model)
|
||||
@@ -60,7 +60,7 @@ class SetupTests: BaseTestCase {
|
||||
|
||||
DataStack(
|
||||
modelName: "Model",
|
||||
bundle: Bundle(for: self.dynamicType),
|
||||
bundle: Bundle(for: type(of: self)),
|
||||
migrationChain: migrationChain
|
||||
)
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class SetupTests: BaseTestCase {
|
||||
|
||||
let stack = DataStack(
|
||||
modelName: "Model",
|
||||
bundle: Bundle(for: self.dynamicType)
|
||||
bundle: Bundle(for: type(of: self))
|
||||
)
|
||||
do {
|
||||
|
||||
@@ -132,7 +132,7 @@ class SetupTests: BaseTestCase {
|
||||
|
||||
let stack = DataStack(
|
||||
modelName: "Model",
|
||||
bundle: Bundle(for: self.dynamicType)
|
||||
bundle: Bundle(for: type(of: self))
|
||||
)
|
||||
do {
|
||||
|
||||
@@ -194,7 +194,7 @@ class SetupTests: BaseTestCase {
|
||||
|
||||
let stack = DataStack(
|
||||
modelName: "Model",
|
||||
bundle: Bundle(for: self.dynamicType)
|
||||
bundle: Bundle(for: type(of: self))
|
||||
)
|
||||
do {
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
dynamic func test_ThatDefaultInMemoryStores_ConfigureCorrectly() {
|
||||
|
||||
let store = InMemoryStore()
|
||||
XCTAssertEqual(store.dynamicType.storeType, NSInMemoryStoreType)
|
||||
XCTAssertEqual(type(of: store).storeType, NSInMemoryStoreType)
|
||||
XCTAssertNil(store.configuration)
|
||||
XCTAssertNil(store.storeOptions)
|
||||
}
|
||||
@@ -46,7 +46,7 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
dynamic func test_ThatCustomInMemoryStores_ConfigureCorrectly() {
|
||||
|
||||
let store = InMemoryStore(configuration: "config1")
|
||||
XCTAssertEqual(store.dynamicType.storeType, NSInMemoryStoreType)
|
||||
XCTAssertEqual(type(of: store).storeType, NSInMemoryStoreType)
|
||||
XCTAssertEqual(store.configuration, "config1")
|
||||
XCTAssertNil(store.storeOptions)
|
||||
}
|
||||
@@ -61,15 +61,15 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
#endif
|
||||
|
||||
let defaultSystemDirectory = FileManager.default
|
||||
.urlsForDirectory(systemDirectorySearchPath, inDomains: .userDomainMask).first!
|
||||
.urls(for: systemDirectorySearchPath, in: .userDomainMask).first!
|
||||
|
||||
let defaultRootDirectory = try! defaultSystemDirectory.appendingPathComponent(
|
||||
let defaultRootDirectory = defaultSystemDirectory.appendingPathComponent(
|
||||
Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack",
|
||||
isDirectory: true
|
||||
)
|
||||
let applicationName = (Bundle.main.objectForInfoDictionaryKey("CFBundleName") as? String) ?? "CoreData"
|
||||
let applicationName = (Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String) ?? "CoreData"
|
||||
|
||||
let defaultFileURL = try! defaultRootDirectory
|
||||
let defaultFileURL = defaultRootDirectory
|
||||
.appendingPathComponent(applicationName, isDirectory: false)
|
||||
.appendingPathExtension("sqlite")
|
||||
|
||||
@@ -81,9 +81,9 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
dynamic func test_ThatDefaultSQLiteStores_ConfigureCorrectly() {
|
||||
|
||||
let store = SQLiteStore()
|
||||
XCTAssertEqual(store.dynamicType.storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(type(of: store).storeType, NSSQLiteStoreType)
|
||||
XCTAssertNil(store.configuration)
|
||||
XCTAssertEqual(store.storeOptions, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
XCTAssertEqual(store.storeOptions as NSDictionary?, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
|
||||
XCTAssertEqual(store.fileURL, SQLiteStore.defaultFileURL)
|
||||
XCTAssertEqual(store.mappingModelBundles, Bundle.allBundles)
|
||||
@@ -93,10 +93,10 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
@objc
|
||||
dynamic func test_ThatFileURLSQLiteStores_ConfigureCorrectly() {
|
||||
|
||||
let fileURL = try! URL(fileURLWithPath: NSTemporaryDirectory())
|
||||
let fileURL = URL(fileURLWithPath: NSTemporaryDirectory())
|
||||
.appendingPathComponent(UUID().uuidString, isDirectory: false)
|
||||
.appendingPathExtension("db")
|
||||
let bundles = [Bundle(for: self.dynamicType)]
|
||||
let bundles = [Bundle(for: type(of: self))]
|
||||
|
||||
let store = SQLiteStore(
|
||||
fileURL: fileURL,
|
||||
@@ -104,9 +104,9 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
mappingModelBundles: bundles,
|
||||
localStorageOptions: .recreateStoreOnModelMismatch
|
||||
)
|
||||
XCTAssertEqual(store.dynamicType.storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(type(of: store).storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(store.configuration, "config1")
|
||||
XCTAssertEqual(store.storeOptions, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
XCTAssertEqual(store.storeOptions as NSDictionary?, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
|
||||
XCTAssertEqual(store.fileURL, fileURL)
|
||||
XCTAssertEqual(store.mappingModelBundles, bundles)
|
||||
@@ -117,7 +117,7 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
dynamic func test_ThatFileNameSQLiteStores_ConfigureCorrectly() {
|
||||
|
||||
let fileName = UUID().uuidString + ".db"
|
||||
let bundles = [Bundle(for: self.dynamicType)]
|
||||
let bundles = [Bundle(for: type(of: self))]
|
||||
|
||||
let store = SQLiteStore(
|
||||
fileName: fileName,
|
||||
@@ -125,11 +125,11 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
mappingModelBundles: bundles,
|
||||
localStorageOptions: .recreateStoreOnModelMismatch
|
||||
)
|
||||
XCTAssertEqual(store.dynamicType.storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(type(of: store).storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(store.configuration, "config1")
|
||||
XCTAssertEqual(store.storeOptions, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
XCTAssertEqual(store.storeOptions as NSDictionary?, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
|
||||
XCTAssertEqual(try! store.fileURL.deletingLastPathComponent(), SQLiteStore.defaultRootDirectory)
|
||||
XCTAssertEqual(store.fileURL.deletingLastPathComponent(), SQLiteStore.defaultRootDirectory)
|
||||
XCTAssertEqual(store.fileURL.lastPathComponent, fileName)
|
||||
XCTAssertEqual(store.mappingModelBundles, bundles)
|
||||
XCTAssertEqual(store.localStorageOptions, [.recreateStoreOnModelMismatch])
|
||||
@@ -144,12 +144,11 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
let systemDirectorySearchPath = FileManager.SearchPathDirectory.applicationSupportDirectory
|
||||
#endif
|
||||
|
||||
let legacyDefaultRootDirectory = FileManager.default.urlsForDirectory(
|
||||
systemDirectorySearchPath,
|
||||
inDomains: .userDomainMask
|
||||
).first!
|
||||
let legacyDefaultRootDirectory = FileManager.default.urls(
|
||||
for: systemDirectorySearchPath,
|
||||
in: .userDomainMask).first!
|
||||
|
||||
let legacyDefaultFileURL = try! legacyDefaultRootDirectory
|
||||
let legacyDefaultFileURL = legacyDefaultRootDirectory
|
||||
.appendingPathComponent(DataStack.applicationName, isDirectory: false)
|
||||
.appendingPathExtension("sqlite")
|
||||
|
||||
@@ -161,9 +160,9 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
dynamic func test_ThatDefaultLegacySQLiteStores_ConfigureCorrectly() {
|
||||
|
||||
let store = LegacySQLiteStore()
|
||||
XCTAssertEqual(store.dynamicType.storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(type(of: store).storeType, NSSQLiteStoreType)
|
||||
XCTAssertNil(store.configuration)
|
||||
XCTAssertEqual(store.storeOptions, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
XCTAssertEqual(store.storeOptions as NSDictionary?, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
|
||||
XCTAssertEqual(store.fileURL, LegacySQLiteStore.defaultFileURL)
|
||||
XCTAssertEqual(store.mappingModelBundles, Bundle.allBundles)
|
||||
@@ -173,10 +172,10 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
@objc
|
||||
dynamic func test_ThatFileURLLegacySQLiteStores_ConfigureCorrectly() {
|
||||
|
||||
let fileURL = try! URL(fileURLWithPath: NSTemporaryDirectory())
|
||||
let fileURL = URL(fileURLWithPath: NSTemporaryDirectory())
|
||||
.appendingPathComponent(UUID().uuidString, isDirectory: false)
|
||||
.appendingPathExtension("db")
|
||||
let bundles = [Bundle(for: self.dynamicType)]
|
||||
let bundles = [Bundle(for: type(of: self))]
|
||||
|
||||
let store = LegacySQLiteStore(
|
||||
fileURL: fileURL,
|
||||
@@ -184,9 +183,9 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
mappingModelBundles: bundles,
|
||||
localStorageOptions: .recreateStoreOnModelMismatch
|
||||
)
|
||||
XCTAssertEqual(store.dynamicType.storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(type(of: store).storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(store.configuration, "config1")
|
||||
XCTAssertEqual(store.storeOptions, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
XCTAssertEqual(store.storeOptions as NSDictionary?, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
|
||||
XCTAssertEqual(store.fileURL, fileURL)
|
||||
XCTAssertEqual(store.mappingModelBundles, bundles)
|
||||
@@ -197,7 +196,7 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
dynamic func test_ThatFileNameLegacySQLiteStores_ConfigureCorrectly() {
|
||||
|
||||
let fileName = UUID().uuidString + ".db"
|
||||
let bundles = [Bundle(for: self.dynamicType)]
|
||||
let bundles = [Bundle(for: type(of: self))]
|
||||
|
||||
let store = LegacySQLiteStore(
|
||||
fileName: fileName,
|
||||
@@ -205,11 +204,11 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
mappingModelBundles: bundles,
|
||||
localStorageOptions: .recreateStoreOnModelMismatch
|
||||
)
|
||||
XCTAssertEqual(store.dynamicType.storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(type(of: store).storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(store.configuration, "config1")
|
||||
XCTAssertEqual(store.storeOptions, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
XCTAssertEqual(store.storeOptions as NSDictionary?, [NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary)
|
||||
|
||||
XCTAssertEqual(try! store.fileURL.deletingLastPathComponent(), LegacySQLiteStore.defaultRootDirectory)
|
||||
XCTAssertEqual(store.fileURL.deletingLastPathComponent(), LegacySQLiteStore.defaultRootDirectory)
|
||||
XCTAssertEqual(store.fileURL.lastPathComponent, fileName)
|
||||
XCTAssertEqual(store.mappingModelBundles, bundles)
|
||||
XCTAssertEqual(store.localStorageOptions, [.recreateStoreOnModelMismatch])
|
||||
|
||||
@@ -41,7 +41,7 @@ final class TransactionTests: BaseTestCase {
|
||||
let testDate = Date()
|
||||
do {
|
||||
|
||||
let createExpectation = self.expectation(withDescription: "create")
|
||||
let createExpectation = self.expectation(description: "create")
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
let object = transaction.create(Into<TestEntity1>())
|
||||
@@ -73,7 +73,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let updateExpectation = self.expectation(withDescription: "update")
|
||||
let updateExpectation = self.expectation(description: "update")
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
guard let object = transaction.fetchOne(From<TestEntity1>()) else {
|
||||
@@ -108,7 +108,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let deleteExpectation = self.expectation(withDescription: "delete")
|
||||
let deleteExpectation = self.expectation(description: "delete")
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
let object = transaction.fetchOne(From<TestEntity1>())
|
||||
@@ -142,7 +142,7 @@ final class TransactionTests: BaseTestCase {
|
||||
let testDate = Date()
|
||||
do {
|
||||
|
||||
let createExpectation = self.expectation(withDescription: "create")
|
||||
let createExpectation = self.expectation(description: "create")
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
let object = transaction.create(Into<TestEntity1>("Config1"))
|
||||
@@ -175,7 +175,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let updateExpectation = self.expectation(withDescription: "update")
|
||||
let updateExpectation = self.expectation(description: "update")
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
guard let object = transaction.fetchOne(From<TestEntity1>("Config1")) else {
|
||||
@@ -211,7 +211,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let deleteExpectation = self.expectation(withDescription: "delete")
|
||||
let deleteExpectation = self.expectation(description: "delete")
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
let object = transaction.fetchOne(From<TestEntity1>("Config1"))
|
||||
@@ -242,7 +242,7 @@ final class TransactionTests: BaseTestCase {
|
||||
|
||||
do {
|
||||
|
||||
let createDiscardExpectation = self.expectation(withDescription: "create-discard")
|
||||
let createDiscardExpectation = self.expectation(description: "create-discard")
|
||||
let loggerExpectations = self.prepareLoggerExpectations([.logWarning])
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
@@ -265,7 +265,7 @@ final class TransactionTests: BaseTestCase {
|
||||
let testDate = Date()
|
||||
do {
|
||||
|
||||
let createExpectation = self.expectation(withDescription: "create")
|
||||
let createExpectation = self.expectation(description: "create")
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
let object = transaction.create(Into<TestEntity1>())
|
||||
@@ -287,7 +287,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let updateDiscardExpectation = self.expectation(withDescription: "update-discard")
|
||||
let updateDiscardExpectation = self.expectation(description: "update-discard")
|
||||
let loggerExpectations = self.prepareLoggerExpectations([.logWarning])
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
@@ -316,7 +316,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let deleteDiscardExpectation = self.expectation(withDescription: "delete-discard")
|
||||
let deleteDiscardExpectation = self.expectation(description: "delete-discard")
|
||||
let loggerExpectations = self.prepareLoggerExpectations([.logWarning])
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
@@ -352,7 +352,7 @@ final class TransactionTests: BaseTestCase {
|
||||
let testDate = Date()
|
||||
do {
|
||||
|
||||
let createExpectation = self.expectation(withDescription: "create")
|
||||
let createExpectation = self.expectation(description: "create")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
let object = transaction.create(Into<TestEntity1>())
|
||||
@@ -386,7 +386,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let updateExpectation = self.expectation(withDescription: "update")
|
||||
let updateExpectation = self.expectation(description: "update")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
guard let object = transaction.fetchOne(From<TestEntity1>()) else {
|
||||
@@ -423,7 +423,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let deleteExpectation = self.expectation(withDescription: "delete")
|
||||
let deleteExpectation = self.expectation(description: "delete")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
let object = transaction.fetchOne(From<TestEntity1>())
|
||||
@@ -460,7 +460,7 @@ final class TransactionTests: BaseTestCase {
|
||||
let testDate = Date()
|
||||
do {
|
||||
|
||||
let createExpectation = self.expectation(withDescription: "create")
|
||||
let createExpectation = self.expectation(description: "create")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
let object = transaction.create(Into<TestEntity1>("Config1"))
|
||||
@@ -495,7 +495,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let updateExpectation = self.expectation(withDescription: "update")
|
||||
let updateExpectation = self.expectation(description: "update")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
guard let object = transaction.fetchOne(From<TestEntity1>("Config1")) else {
|
||||
@@ -533,7 +533,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let deleteExpectation = self.expectation(withDescription: "delete")
|
||||
let deleteExpectation = self.expectation(description: "delete")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
let object = transaction.fetchOne(From<TestEntity1>("Config1"))
|
||||
@@ -568,7 +568,7 @@ final class TransactionTests: BaseTestCase {
|
||||
|
||||
do {
|
||||
|
||||
let createDiscardExpectation = self.expectation(withDescription: "create-discard")
|
||||
let createDiscardExpectation = self.expectation(description: "create-discard")
|
||||
let loggerExpectations = self.prepareLoggerExpectations([.logWarning])
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
@@ -585,7 +585,7 @@ final class TransactionTests: BaseTestCase {
|
||||
let testDate = Date()
|
||||
do {
|
||||
|
||||
let createExpectation = self.expectation(withDescription: "create")
|
||||
let createExpectation = self.expectation(description: "create")
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 0)
|
||||
@@ -612,7 +612,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let updateDiscardExpectation = self.expectation(withDescription: "update-discard")
|
||||
let updateDiscardExpectation = self.expectation(description: "update-discard")
|
||||
let loggerExpectations = self.prepareLoggerExpectations([.logWarning])
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
@@ -631,7 +631,7 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
do {
|
||||
|
||||
let deleteDiscardExpectation = self.expectation(withDescription: "delete-discard")
|
||||
let deleteDiscardExpectation = self.expectation(description: "delete-discard")
|
||||
let loggerExpectations = self.prepareLoggerExpectations([.logWarning])
|
||||
stack.beginAsynchronous { (transaction) in
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ final class TweakTests: XCTestCase {
|
||||
@objc
|
||||
dynamic func test_ThatTweakClauses_ApplyToFetchRequestsCorrectly() {
|
||||
|
||||
let predicate = Predicate(format: "%K == %@", "key", "value")
|
||||
let predicate = NSPredicate(format: "%K == %@", "key", "value")
|
||||
let tweak = Tweak {
|
||||
|
||||
$0.fetchOffset = 100
|
||||
|
||||
@@ -41,18 +41,18 @@ final class WhereTests: XCTestCase {
|
||||
let whereClause = Where()
|
||||
XCTAssertEqual(whereClause, Where(true))
|
||||
XCTAssertNotEqual(whereClause, Where(false))
|
||||
XCTAssertEqual(whereClause.predicate, Predicate(value: true))
|
||||
XCTAssertEqual(whereClause.predicate, NSPredicate(value: true))
|
||||
}
|
||||
do {
|
||||
|
||||
let whereClause = Where(true)
|
||||
XCTAssertEqual(whereClause, Where())
|
||||
XCTAssertNotEqual(whereClause, Where(false))
|
||||
XCTAssertEqual(whereClause.predicate, Predicate(value: true))
|
||||
XCTAssertEqual(whereClause.predicate, NSPredicate(value: true))
|
||||
}
|
||||
do {
|
||||
|
||||
let predicate = Predicate(format: "%K == %@", "key", "value")
|
||||
let predicate = NSPredicate(format: "%K == %@", "key", "value")
|
||||
let whereClause = Where(predicate)
|
||||
XCTAssertEqual(whereClause, Where(predicate))
|
||||
XCTAssertEqual(whereClause.predicate, predicate)
|
||||
@@ -60,28 +60,28 @@ final class WhereTests: XCTestCase {
|
||||
do {
|
||||
|
||||
let whereClause = Where("%K == %@", "key", "value")
|
||||
let predicate = Predicate(format: "%K == %@", "key", "value")
|
||||
let predicate = NSPredicate(format: "%K == %@", "key", "value")
|
||||
XCTAssertEqual(whereClause, Where(predicate))
|
||||
XCTAssertEqual(whereClause.predicate, predicate)
|
||||
}
|
||||
do {
|
||||
|
||||
let whereClause = Where("%K == %@", argumentArray: ["key", "value"])
|
||||
let predicate = Predicate(format: "%K == %@", "key", "value")
|
||||
let predicate = NSPredicate(format: "%K == %@", "key", "value")
|
||||
XCTAssertEqual(whereClause, Where(predicate))
|
||||
XCTAssertEqual(whereClause.predicate, predicate)
|
||||
}
|
||||
do {
|
||||
|
||||
let whereClause = Where("key", isEqualTo: "value")
|
||||
let predicate = Predicate(format: "%K == %@", "key", "value")
|
||||
let predicate = NSPredicate(format: "%K == %@", "key", "value")
|
||||
XCTAssertEqual(whereClause, Where(predicate))
|
||||
XCTAssertEqual(whereClause.predicate, predicate)
|
||||
}
|
||||
do {
|
||||
|
||||
let whereClause = Where("key", isMemberOf: ["value1", "value2", "value3"])
|
||||
let predicate = Predicate(format: "%K IN %@", "key", ["value1", "value2", "value3"])
|
||||
let predicate = NSPredicate(format: "%K IN %@", "key", ["value1", "value2", "value3"])
|
||||
XCTAssertEqual(whereClause, Where(predicate))
|
||||
XCTAssertEqual(whereClause.predicate, predicate)
|
||||
}
|
||||
@@ -97,7 +97,7 @@ final class WhereTests: XCTestCase {
|
||||
do {
|
||||
|
||||
let notWhere = !whereClause1
|
||||
let notPredicate = CompoundPredicate(
|
||||
let notPredicate = NSCompoundPredicate(
|
||||
type: .not,
|
||||
subpredicates: [whereClause1.predicate]
|
||||
)
|
||||
@@ -107,10 +107,10 @@ final class WhereTests: XCTestCase {
|
||||
do {
|
||||
|
||||
let andWhere = whereClause1 && whereClause2 && whereClause3
|
||||
let andPredicate = CompoundPredicate(
|
||||
let andPredicate = NSCompoundPredicate(
|
||||
type: .and,
|
||||
subpredicates: [
|
||||
CompoundPredicate(
|
||||
NSCompoundPredicate(
|
||||
type: .and,
|
||||
subpredicates: [whereClause1.predicate, whereClause2.predicate]
|
||||
),
|
||||
@@ -123,10 +123,10 @@ final class WhereTests: XCTestCase {
|
||||
do {
|
||||
|
||||
let orWhere = whereClause1 || whereClause2 || whereClause3
|
||||
let orPredicate = CompoundPredicate(
|
||||
let orPredicate = NSCompoundPredicate(
|
||||
type: .or,
|
||||
subpredicates: [
|
||||
CompoundPredicate(
|
||||
NSCompoundPredicate(
|
||||
type: .or,
|
||||
subpredicates: [whereClause1.predicate, whereClause2.predicate]
|
||||
),
|
||||
|
||||
@@ -41,11 +41,5 @@ targets = []
|
||||
let package = Package(
|
||||
name: "CoreStore",
|
||||
targets: targets,
|
||||
dependencies: [
|
||||
.Package(
|
||||
url: "https://github.com/JohnEstropia/GCDKit.git",
|
||||
"1.2.6"
|
||||
)
|
||||
],
|
||||
exclude: ["Carthage", "CoreStoreDemo", "Sources/libA/images"]
|
||||
)
|
||||
|
||||
@@ -1084,7 +1084,7 @@ The `"count(friends)"` key name was automatically used by CoreStore, but you can
|
||||
```swift
|
||||
let personJSON = CoreStore.queryAttributes(
|
||||
From<MyPersonEntity>(),
|
||||
Select("name", .count("friends", As: "friendsCount"))
|
||||
Select("name", .count("friends", as: "friendsCount"))
|
||||
)
|
||||
```
|
||||
which now returns:
|
||||
@@ -1107,7 +1107,7 @@ The `GroupBy` clause lets you group results by a specified attribute/aggregate.
|
||||
```swift
|
||||
let personJSON = CoreStore.queryAttributes(
|
||||
From<MyPersonEntity>(),
|
||||
Select("age", .count("age", As: "count")),
|
||||
Select("age", .count("age", as: "count")),
|
||||
GroupBy("age")
|
||||
)
|
||||
```
|
||||
@@ -1431,8 +1431,6 @@ to your target's `GCC_PREPROCESSOR_DEFINITIONS` build setting.
|
||||
- Requires:
|
||||
- iOS 7 SDK and above
|
||||
- Swift 2.2 (Xcode 7.3)
|
||||
- Dependencies:
|
||||
- [GCDKit](https://github.com/JohnEstropia/GCDKit)
|
||||
- Other notes:
|
||||
- The `com.apple.CoreData.ConcurrencyDebug` debug argument should be turned off for the app. CoreStore already guarantees safety for you by making the main context read-only, and by only executing transactions serially.
|
||||
|
||||
@@ -1446,7 +1444,6 @@ This installs CoreStore as a framework. Declare `import CoreStore` in your swift
|
||||
In your `Cartfile`, add
|
||||
```
|
||||
github "JohnEstropia/CoreStore" >= 2.0.0
|
||||
github "JohnEstropia/GCDKit" >= 1.2.5
|
||||
```
|
||||
and run
|
||||
```
|
||||
|
||||
@@ -38,10 +38,10 @@ public extension NSManagedObject {
|
||||
- returns: the primitive value for the KVC key
|
||||
*/
|
||||
@nonobjc
|
||||
public func accessValueForKVCKey(_ KVCKey: KeyPath) -> AnyObject? {
|
||||
public func accessValueForKVCKey(_ KVCKey: KeyPath) -> Any? {
|
||||
|
||||
self.willAccessValue(forKey: KVCKey)
|
||||
let primitiveValue: AnyObject? = self.primitiveValue(forKey: KVCKey)
|
||||
let primitiveValue: Any? = self.primitiveValue(forKey: KVCKey)
|
||||
self.didAccessValue(forKey: KVCKey)
|
||||
|
||||
return primitiveValue
|
||||
@@ -54,7 +54,7 @@ public extension NSManagedObject {
|
||||
- parameter KVCKey: the KVC key
|
||||
*/
|
||||
@nonobjc
|
||||
public func setValue(_ value: AnyObject?, forKVCKey KVCKey: KeyPath) {
|
||||
public func setValue(_ value: Any?, forKVCKey KVCKey: KeyPath) {
|
||||
|
||||
self.willChangeValue(forKey: KVCKey)
|
||||
self.setPrimitiveValue(value, forKey: KVCKey)
|
||||
|
||||
@@ -79,7 +79,8 @@ public extension Progress {
|
||||
private final class ProgressObserver: NSObject {
|
||||
|
||||
private unowned let progress: Progress
|
||||
private var progressHandler: ((_ progress: Progress) -> Void)? {
|
||||
|
||||
fileprivate var progressHandler: ((_ progress: Progress) -> Void)? {
|
||||
|
||||
didSet {
|
||||
|
||||
@@ -105,7 +106,7 @@ private final class ProgressObserver: NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
private init(_ progress: Progress) {
|
||||
fileprivate init(_ progress: Progress) {
|
||||
|
||||
self.progress = progress
|
||||
super.init()
|
||||
@@ -120,7 +121,7 @@ private final class ProgressObserver: NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
override func observeValue(forKeyPath keyPath: String?, of object: AnyObject?, change: [NSKeyValueChangeKey : AnyObject]?, context: UnsafeMutablePointer<Void>?) {
|
||||
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
||||
|
||||
guard let progress = object as? Progress,
|
||||
progress == self.progress,
|
||||
@@ -131,7 +132,7 @@ private final class ProgressObserver: NSObject {
|
||||
|
||||
DispatchQueue.main.async { [weak self] () -> Void in
|
||||
|
||||
self?.progressHandler?(progress: progress)
|
||||
self?.progressHandler?(progress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ public extension BaseDataTransaction {
|
||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||
*/
|
||||
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[NSString: AnyObject]]? {
|
||||
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.isRunningInAllowedQueue(),
|
||||
@@ -336,7 +336,7 @@ public extension BaseDataTransaction {
|
||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||
*/
|
||||
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[NSString: AnyObject]]? {
|
||||
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.isRunningInAllowedQueue(),
|
||||
|
||||
@@ -115,10 +115,10 @@ public struct OrderBy: FetchClause, QueryClause, DeleteClause, Hashable {
|
||||
switch sortKey {
|
||||
|
||||
case .ascending(let keyPath):
|
||||
return SortDescriptor(key: keyPath, ascending: true)
|
||||
return NSSortDescriptor(key: keyPath, ascending: true)
|
||||
|
||||
case .descending(let keyPath):
|
||||
return SortDescriptor(key: keyPath, ascending: false)
|
||||
return NSSortDescriptor(key: keyPath, ascending: false)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -44,7 +44,7 @@ public protocol SelectValueResultType: SelectResultType {
|
||||
|
||||
static var attributeType: NSAttributeType { get }
|
||||
|
||||
static func fromResultObject(_ result: AnyObject) -> Self?
|
||||
static func fromResultObject(_ result: Any) -> Self?
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public protocol SelectValueResultType: SelectResultType {
|
||||
*/
|
||||
public protocol SelectAttributesResultType: SelectResultType {
|
||||
|
||||
static func fromResultObjects(_ result: [AnyObject]) -> [[NSString: AnyObject]]
|
||||
static func fromResultObjects(_ result: [Any]) -> [[String: Any]]
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
|
||||
*/
|
||||
public static func average(_ keyPath: KeyPath, As alias: KeyPath? = nil) -> SelectTerm {
|
||||
public static func average(_ keyPath: KeyPath, as alias: KeyPath? = nil) -> SelectTerm {
|
||||
|
||||
return ._aggregate(
|
||||
function: "average:",
|
||||
@@ -125,7 +125,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for a count query
|
||||
*/
|
||||
public static func count(_ keyPath: KeyPath, As alias: KeyPath? = nil) -> SelectTerm {
|
||||
public static func count(_ keyPath: KeyPath, as alias: KeyPath? = nil) -> SelectTerm {
|
||||
|
||||
return ._aggregate(
|
||||
function: "count:",
|
||||
@@ -147,7 +147,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
|
||||
*/
|
||||
public static func maximum(_ keyPath: KeyPath, As alias: KeyPath? = nil) -> SelectTerm {
|
||||
public static func maximum(_ keyPath: KeyPath, as alias: KeyPath? = nil) -> SelectTerm {
|
||||
|
||||
return ._aggregate(
|
||||
function: "max:",
|
||||
@@ -169,7 +169,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
|
||||
*/
|
||||
public static func minimum(_ keyPath: KeyPath, As alias: KeyPath? = nil) -> SelectTerm {
|
||||
public static func minimum(_ keyPath: KeyPath, as alias: KeyPath? = nil) -> SelectTerm {
|
||||
|
||||
return ._aggregate(
|
||||
function: "min:",
|
||||
@@ -191,7 +191,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||
*/
|
||||
public static func sum(_ keyPath: KeyPath, As alias: KeyPath? = nil) -> SelectTerm {
|
||||
public static func sum(_ keyPath: KeyPath, as alias: KeyPath? = nil) -> SelectTerm {
|
||||
|
||||
return ._aggregate(
|
||||
function: "sum:",
|
||||
@@ -214,7 +214,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "objecID" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||
*/
|
||||
public static func objectID(As alias: KeyPath? = nil) -> SelectTerm {
|
||||
public static func objectID(as alias: KeyPath? = nil) -> SelectTerm {
|
||||
|
||||
return ._identity(
|
||||
alias: alias ?? "objectID",
|
||||
@@ -402,7 +402,7 @@ extension Bool: SelectValueResultType {
|
||||
return .booleanAttributeType
|
||||
}
|
||||
|
||||
public static func fromResultObject(_ result: AnyObject) -> Bool? {
|
||||
public static func fromResultObject(_ result: Any) -> Bool? {
|
||||
switch result {
|
||||
|
||||
case let decimal as NSDecimalNumber:
|
||||
@@ -429,7 +429,7 @@ extension Int8: SelectValueResultType {
|
||||
return .integer64AttributeType
|
||||
}
|
||||
|
||||
public static func fromResultObject(_ result: AnyObject) -> Int8? {
|
||||
public static func fromResultObject(_ result: Any) -> Int8? {
|
||||
|
||||
guard let value = (result as? NSNumber)?.int64Value else {
|
||||
|
||||
@@ -449,7 +449,7 @@ extension Int16: SelectValueResultType {
|
||||
return .integer64AttributeType
|
||||
}
|
||||
|
||||
public static func fromResultObject(_ result: AnyObject) -> Int16? {
|
||||
public static func fromResultObject(_ result: Any) -> Int16? {
|
||||
|
||||
guard let value = (result as? NSNumber)?.int64Value else {
|
||||
|
||||
@@ -469,7 +469,7 @@ extension Int32: SelectValueResultType {
|
||||
return .integer64AttributeType
|
||||
}
|
||||
|
||||
public static func fromResultObject(_ result: AnyObject) -> Int32? {
|
||||
public static func fromResultObject(_ result: Any) -> Int32? {
|
||||
|
||||
guard let value = (result as? NSNumber)?.int64Value else {
|
||||
|
||||
@@ -489,7 +489,7 @@ extension Int64: SelectValueResultType {
|
||||
return .integer64AttributeType
|
||||
}
|
||||
|
||||
public static func fromResultObject(_ result: AnyObject) -> Int64? {
|
||||
public static func fromResultObject(_ result: Any) -> Int64? {
|
||||
|
||||
return (result as? NSNumber)?.int64Value
|
||||
}
|
||||
@@ -505,7 +505,7 @@ extension Int: SelectValueResultType {
|
||||
return .integer64AttributeType
|
||||
}
|
||||
|
||||
public static func fromResultObject(_ result: AnyObject) -> Int? {
|
||||
public static func fromResultObject(_ result: Any) -> Int? {
|
||||
|
||||
guard let value = (result as? NSNumber)?.int64Value else {
|
||||
|
||||
@@ -525,7 +525,7 @@ extension Double: SelectValueResultType {
|
||||
return .doubleAttributeType
|
||||
}
|
||||
|
||||
public static func fromResultObject(_ result: AnyObject) -> Double? {
|
||||
public static func fromResultObject(_ result: Any) -> Double? {
|
||||
|
||||
return (result as? NSNumber)?.doubleValue
|
||||
}
|
||||
@@ -541,7 +541,7 @@ extension Float: SelectValueResultType {
|
||||
return .floatAttributeType
|
||||
}
|
||||
|
||||
public static func fromResultObject(_ result: AnyObject) -> Float? {
|
||||
public static func fromResultObject(_ result: Any) -> Float? {
|
||||
|
||||
return (result as? NSNumber)?.floatValue
|
||||
}
|
||||
@@ -557,7 +557,7 @@ extension String: SelectValueResultType {
|
||||
return .stringAttributeType
|
||||
}
|
||||
|
||||
public static func fromResultObject(_ result: AnyObject) -> String? {
|
||||
public static func fromResultObject(_ result: Any) -> String? {
|
||||
|
||||
return result as? String
|
||||
}
|
||||
@@ -573,7 +573,7 @@ extension Date: SelectValueResultType {
|
||||
return .dateAttributeType
|
||||
}
|
||||
|
||||
public static func fromResultObject(_ result: AnyObject) -> Date? {
|
||||
public static func fromResultObject(_ result: Any) -> Date? {
|
||||
|
||||
return result as? Date
|
||||
}
|
||||
@@ -589,7 +589,7 @@ extension Data: SelectValueResultType {
|
||||
return .binaryDataAttributeType
|
||||
}
|
||||
|
||||
public static func fromResultObject(_ result: AnyObject) -> Data? {
|
||||
public static func fromResultObject(_ result: Any) -> Data? {
|
||||
|
||||
return result as? Data
|
||||
}
|
||||
@@ -605,9 +605,9 @@ extension NSNumber: SelectValueResultType {
|
||||
return .integer64AttributeType
|
||||
}
|
||||
|
||||
public class func fromResultObject(_ result: AnyObject) -> Self? {
|
||||
public class func fromResultObject(_ result: Any) -> Self? {
|
||||
|
||||
func forceCast<T: NSNumber>(_ object: AnyObject) -> T? {
|
||||
func forceCast<T: NSNumber>(_ object: Any) -> T? {
|
||||
|
||||
return (object as? T)
|
||||
}
|
||||
@@ -625,9 +625,9 @@ extension NSString: SelectValueResultType {
|
||||
return .stringAttributeType
|
||||
}
|
||||
|
||||
public class func fromResultObject(_ result: AnyObject) -> Self? {
|
||||
public class func fromResultObject(_ result: Any) -> Self? {
|
||||
|
||||
func forceCast<T: NSString>(_ object: AnyObject) -> T? {
|
||||
func forceCast<T: NSString>(_ object: Any) -> T? {
|
||||
|
||||
return (object as? T)
|
||||
}
|
||||
@@ -645,9 +645,9 @@ extension NSDecimalNumber {
|
||||
return .decimalAttributeType
|
||||
}
|
||||
|
||||
public override class func fromResultObject(_ result: AnyObject) -> Self? {
|
||||
public override class func fromResultObject(_ result: Any) -> Self? {
|
||||
|
||||
func forceCast<T: NSDecimalNumber>(_ object: AnyObject) -> T? {
|
||||
func forceCast<T: NSDecimalNumber>(_ object: Any) -> T? {
|
||||
|
||||
return (object as? T)
|
||||
}
|
||||
@@ -665,9 +665,9 @@ extension NSDate: SelectValueResultType {
|
||||
return .dateAttributeType
|
||||
}
|
||||
|
||||
public class func fromResultObject(_ result: AnyObject) -> Self? {
|
||||
public class func fromResultObject(_ result: Any) -> Self? {
|
||||
|
||||
func forceCast<T: NSDate>(_ object: AnyObject) -> T? {
|
||||
func forceCast<T: NSDate>(_ object: Any) -> T? {
|
||||
|
||||
return (object as? T)
|
||||
}
|
||||
@@ -685,9 +685,9 @@ extension NSData: SelectValueResultType {
|
||||
return .binaryDataAttributeType
|
||||
}
|
||||
|
||||
public class func fromResultObject(_ result: AnyObject) -> Self? {
|
||||
public class func fromResultObject(_ result: Any) -> Self? {
|
||||
|
||||
func forceCast<T: NSData>(_ object: AnyObject) -> T? {
|
||||
func forceCast<T: NSData>(_ object: Any) -> T? {
|
||||
|
||||
return (object as? T)
|
||||
}
|
||||
@@ -705,9 +705,9 @@ extension NSManagedObjectID: SelectValueResultType {
|
||||
return .objectIDAttributeType
|
||||
}
|
||||
|
||||
public class func fromResultObject(_ result: AnyObject) -> Self? {
|
||||
public class func fromResultObject(_ result: Any) -> Self? {
|
||||
|
||||
func forceCast<T: NSManagedObjectID>(_ object: AnyObject) -> T? {
|
||||
func forceCast<T: NSManagedObjectID>(_ object: Any) -> T? {
|
||||
|
||||
return (object as? T)
|
||||
}
|
||||
@@ -722,9 +722,9 @@ extension NSDictionary: SelectAttributesResultType {
|
||||
|
||||
// MARK: SelectAttributesResultType
|
||||
|
||||
public class func fromResultObjects(_ result: [AnyObject]) -> [[NSString: AnyObject]] {
|
||||
public class func fromResultObjects(_ result: [Any]) -> [[String: Any]] {
|
||||
|
||||
return result as! [[NSString: AnyObject]]
|
||||
return result as! [[String: Any]]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,7 +761,7 @@ internal extension Collection where Iterator.Element == SelectTerm {
|
||||
}
|
||||
}
|
||||
|
||||
var propertiesToFetch = [AnyObject]()
|
||||
var propertiesToFetch = [Any]()
|
||||
for term in self {
|
||||
|
||||
switch term {
|
||||
|
||||
@@ -79,7 +79,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
||||
- parameter format: the format string for the predicate
|
||||
- parameter args: the arguments for `format`
|
||||
*/
|
||||
public init(_ format: String, _ args: NSObject...) {
|
||||
public init(_ format: String, _ args: Any...) {
|
||||
|
||||
self.init(NSPredicate(format: format, argumentArray: args))
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
||||
- parameter format: the format string for the predicate
|
||||
- parameter argumentArray: the arguments for `format`
|
||||
*/
|
||||
public init(_ format: String, argumentArray: [NSObject]?) {
|
||||
public init(_ format: String, argumentArray: [Any]?) {
|
||||
|
||||
self.init(NSPredicate(format: format, argumentArray: argumentArray))
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
||||
- parameter keyPath: the keyPath to compare with
|
||||
- parameter value: the arguments for the `==` operator
|
||||
*/
|
||||
public init(_ keyPath: KeyPath, isEqualTo value: NSObject?) {
|
||||
public init(_ keyPath: KeyPath, isEqualTo value: Any?) {
|
||||
|
||||
self.init(value == nil
|
||||
? NSPredicate(format: "\(keyPath) == nil")
|
||||
@@ -114,7 +114,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
||||
- parameter keyPath: the keyPath to compare with
|
||||
- parameter list: the array to check membership of
|
||||
*/
|
||||
public init(_ keyPath: KeyPath, isMemberOf list: [NSObject]) {
|
||||
public init(_ keyPath: KeyPath, isMemberOf list: [Any]) {
|
||||
|
||||
self.init(NSPredicate(format: "\(keyPath) IN %@", list))
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
||||
- parameter keyPath: the keyPath to compare with
|
||||
- parameter list: the sequence to check membership of
|
||||
*/
|
||||
public init<S: Sequence>(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element: NSObject {
|
||||
public init<S: Sequence>(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element: Any {
|
||||
|
||||
self.init(NSPredicate(format: "\(keyPath) IN %@", Array(list) as NSArray))
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ public extension CoreStore {
|
||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||
*/
|
||||
public static func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[NSString: AnyObject]]? {
|
||||
public static func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
||||
|
||||
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
|
||||
}
|
||||
@@ -250,7 +250,7 @@ public extension CoreStore {
|
||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||
*/
|
||||
public static func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[NSString: AnyObject]]? {
|
||||
public static func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
||||
|
||||
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ public extension DataStack {
|
||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||
*/
|
||||
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[NSString: AnyObject]]? {
|
||||
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
||||
|
||||
CoreStore.assert(
|
||||
Thread.isMainThread,
|
||||
@@ -316,7 +316,7 @@ public extension DataStack {
|
||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||
*/
|
||||
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[NSString: AnyObject]]? {
|
||||
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
||||
|
||||
CoreStore.assert(
|
||||
Thread.isMainThread,
|
||||
|
||||
@@ -36,7 +36,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
|
||||
// MARK: Internal
|
||||
|
||||
@nonobjc
|
||||
internal convenience init<T: NSManagedObject>(dataStack: DataStack, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
||||
internal convenience init<T: NSManagedObject>(dataStack: DataStack, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
||||
|
||||
self.init(
|
||||
context: dataStack.mainContext,
|
||||
@@ -48,7 +48,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal init<T: NSManagedObject>(context: NSManagedObjectContext, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
||||
internal init<T: NSManagedObject>(context: NSManagedObjectContext, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
||||
|
||||
_ = from?.applyToFetchRequest(
|
||||
fetchRequest,
|
||||
|
||||
@@ -30,22 +30,22 @@ import Foundation
|
||||
|
||||
internal extension DispatchQueue {
|
||||
|
||||
internal convenience init(serialWith label: String) {
|
||||
internal convenience init(serialWith label: String, qos: DispatchQoS = .default) {
|
||||
|
||||
self.init(
|
||||
label: label,
|
||||
qos: .default,
|
||||
attributes: .allZeros,
|
||||
qos: qos,
|
||||
attributes: [],
|
||||
autoreleaseFrequency: .inherit,
|
||||
target: nil
|
||||
)
|
||||
}
|
||||
|
||||
internal convenience init(concurrentWith label: String) {
|
||||
internal convenience init(concurrentWith label: String, qos: DispatchQoS = .default) {
|
||||
|
||||
self.init(
|
||||
label: label,
|
||||
qos: .default,
|
||||
qos: qos,
|
||||
attributes: .concurrent,
|
||||
autoreleaseFrequency: .inherit,
|
||||
target: nil
|
||||
@@ -62,20 +62,20 @@ internal extension DispatchQueue {
|
||||
|
||||
internal func cs_sync<T>(_ closure: () throws -> T) rethrows -> T {
|
||||
|
||||
return self.sync { autoreleasepool(invoking: closure) }
|
||||
return try self.sync { try autoreleasepool(invoking: closure) }
|
||||
}
|
||||
|
||||
internal func cs_async(_ closure: () -> Void) {
|
||||
internal func cs_async(_ closure: @escaping () -> Void) {
|
||||
|
||||
self.async { autoreleasepool(invoking: closure) }
|
||||
}
|
||||
|
||||
internal func cs_barrierSync<T>(_ closure: () throws -> T) rethrows -> T {
|
||||
|
||||
return self.sync(flags: .barrier) { autoreleasepool(invoking: closure) }
|
||||
return try self.sync(flags: .barrier) { try autoreleasepool(invoking: closure) }
|
||||
}
|
||||
|
||||
internal func cs_barrierAsync(_ closure: () -> Void) {
|
||||
internal func cs_barrierAsync(_ closure: @escaping () -> Void) {
|
||||
|
||||
self.async(flags: .barrier) { autoreleasepool(invoking: closure) }
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import CoreData
|
||||
|
||||
internal protocol FetchedResultsControllerHandler: class {
|
||||
|
||||
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: AnyObject, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?)
|
||||
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: Any, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?)
|
||||
|
||||
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType)
|
||||
|
||||
@@ -101,7 +101,7 @@ internal final class FetchedResultsControllerDelegate<EntityType: NSManagedObjec
|
||||
}
|
||||
|
||||
@objc
|
||||
dynamic func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: AnyObject, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
|
||||
dynamic func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
|
||||
|
||||
guard self.enabled else {
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import Foundation
|
||||
|
||||
// MARK: Associated Objects
|
||||
|
||||
internal func cs_getAssociatedObjectForKey<T: AnyObject>(_ key: UnsafeRawPointer, inObject object: AnyObject) -> T? {
|
||||
internal func cs_getAssociatedObjectForKey<T: AnyObject>(_ key: UnsafeRawPointer, inObject object: Any) -> T? {
|
||||
|
||||
switch objc_getAssociatedObject(object, key) {
|
||||
|
||||
@@ -42,17 +42,17 @@ internal func cs_getAssociatedObjectForKey<T: AnyObject>(_ key: UnsafeRawPointer
|
||||
}
|
||||
}
|
||||
|
||||
internal func cs_setAssociatedRetainedObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: AnyObject) {
|
||||
internal func cs_setAssociatedRetainedObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: Any) {
|
||||
|
||||
objc_setAssociatedObject(object, key, associatedObject, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||
}
|
||||
|
||||
internal func cs_setAssociatedCopiedObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: AnyObject) {
|
||||
internal func cs_setAssociatedCopiedObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: Any) {
|
||||
|
||||
objc_setAssociatedObject(object, key, associatedObject, .OBJC_ASSOCIATION_COPY_NONATOMIC)
|
||||
}
|
||||
|
||||
internal func cs_setAssociatedWeakObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: AnyObject) {
|
||||
internal func cs_setAssociatedWeakObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: Any) {
|
||||
|
||||
if let associatedObject = associatedObject {
|
||||
|
||||
|
||||
@@ -425,7 +425,7 @@ internal extension NSManagedObjectContext {
|
||||
@nonobjc
|
||||
internal func queryValue<U: SelectValueResultType>(_ selectTerms: [SelectTerm], fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> U? {
|
||||
|
||||
var fetchResults: [AnyObject]?
|
||||
var fetchResults: [Any]?
|
||||
var fetchError: Error?
|
||||
self.performAndWait {
|
||||
|
||||
@@ -441,7 +441,7 @@ internal extension NSManagedObjectContext {
|
||||
if let fetchResults = fetchResults {
|
||||
|
||||
if let rawResult = fetchResults.first as? NSDictionary,
|
||||
let rawObject: AnyObject = rawResult[selectTerms.keyPathForFirstSelectTerm()] {
|
||||
let rawObject = rawResult[selectTerms.keyPathForFirstSelectTerm()] {
|
||||
|
||||
return Select<U>.ReturnType.fromResultObject(rawObject)
|
||||
}
|
||||
@@ -456,9 +456,9 @@ internal extension NSManagedObjectContext {
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func queryValue(_ selectTerms: [SelectTerm], fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> AnyObject? {
|
||||
internal func queryValue(_ selectTerms: [SelectTerm], fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> Any? {
|
||||
|
||||
var fetchResults: [AnyObject]?
|
||||
var fetchResults: [Any]?
|
||||
var fetchError: Error?
|
||||
self.performAndWait {
|
||||
|
||||
@@ -474,7 +474,7 @@ internal extension NSManagedObjectContext {
|
||||
if let fetchResults = fetchResults {
|
||||
|
||||
if let rawResult = fetchResults.first as? NSDictionary,
|
||||
let rawObject: AnyObject = rawResult[selectTerms.keyPathForFirstSelectTerm()] {
|
||||
let rawObject = rawResult[selectTerms.keyPathForFirstSelectTerm()] {
|
||||
|
||||
return rawObject
|
||||
}
|
||||
@@ -492,13 +492,13 @@ internal extension NSManagedObjectContext {
|
||||
// MARK: Internal: Attributes
|
||||
|
||||
@nonobjc
|
||||
internal func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[NSString: AnyObject]]? {
|
||||
internal func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
||||
|
||||
return self.queryAttributes(from, selectClause, queryClauses)
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[NSString: AnyObject]]? {
|
||||
internal func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest<NSFetchRequestResult>()
|
||||
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
||||
@@ -516,9 +516,9 @@ internal extension NSManagedObjectContext {
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func queryAttributes(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> [[NSString: AnyObject]]? {
|
||||
internal func queryAttributes(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> [[String: Any]]? {
|
||||
|
||||
var fetchResults: [AnyObject]?
|
||||
var fetchResults: [Any]?
|
||||
var fetchError: Error?
|
||||
self.performAndWait {
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
DispatchQueue.main.async {
|
||||
|
||||
completion(result: SaveResult(hasChanges: false))
|
||||
completion(SaveResult(hasChanges: false))
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -175,7 +175,7 @@ internal extension NSManagedObjectContext {
|
||||
)
|
||||
DispatchQueue.main.async {
|
||||
|
||||
completion(result: SaveResult(saveError))
|
||||
completion(SaveResult(saveError))
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -188,7 +188,7 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
DispatchQueue.main.async {
|
||||
|
||||
completion(result: SaveResult(hasChanges: true))
|
||||
completion(SaveResult(hasChanges: true))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ internal extension NSManagedObjectModel {
|
||||
}
|
||||
|
||||
let modelFileURL = URL(fileURLWithPath: modelFilePath)
|
||||
let versionInfoPlistURL = try! modelFileURL.appendingPathComponent("VersionInfo.plist", isDirectory: false)
|
||||
let versionInfoPlistURL = modelFileURL.appendingPathComponent("VersionInfo.plist", isDirectory: false)
|
||||
|
||||
guard let versionInfo = NSDictionary(contentsOf: versionInfoPlistURL),
|
||||
let versionHashes = versionInfo["NSManagedObjectModel_VersionHashes"] as? [String: AnyObject] else {
|
||||
@@ -84,7 +84,7 @@ internal extension NSManagedObjectModel {
|
||||
var modelVersionFileURL: URL?
|
||||
for modelVersion in modelVersions {
|
||||
|
||||
let fileURL = try! modelFileURL.appendingPathComponent("\(modelVersion).mom", isDirectory: false)
|
||||
let fileURL = modelFileURL.appendingPathComponent("\(modelVersion).mom", isDirectory: false)
|
||||
|
||||
if modelVersion == currentModelVersion {
|
||||
|
||||
@@ -190,7 +190,7 @@ internal extension NSManagedObjectModel {
|
||||
return nil
|
||||
}
|
||||
|
||||
let versionModelFileURL = try! modelFileURL.appendingPathComponent("\(modelVersion).mom", isDirectory: false)
|
||||
let versionModelFileURL = modelFileURL.appendingPathComponent("\(modelVersion).mom", isDirectory: false)
|
||||
guard let model = NSManagedObjectModel(contentsOf: versionModelFileURL) else {
|
||||
|
||||
return nil
|
||||
@@ -203,7 +203,7 @@ internal extension NSManagedObjectModel {
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal subscript(metadata: [String: AnyObject]) -> NSManagedObjectModel? {
|
||||
internal subscript(metadata: [String: Any]) -> NSManagedObjectModel? {
|
||||
|
||||
guard let modelHashes = metadata[NSStoreModelVersionHashesKey] as? [String : Data] else {
|
||||
|
||||
@@ -227,7 +227,7 @@ internal extension NSManagedObjectModel {
|
||||
|
||||
get {
|
||||
|
||||
return try! self.modelVersionFileURL?.deletingLastPathComponent()
|
||||
return self.modelVersionFileURL?.deletingLastPathComponent()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,15 +66,15 @@ internal extension NSPersistentStore {
|
||||
|
||||
// MARK: - StorageObject
|
||||
|
||||
private class StorageObject: NSObject {
|
||||
fileprivate class StorageObject: NSObject {
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@nonobjc
|
||||
private let storageInterface: StorageInterface?
|
||||
fileprivate let storageInterface: StorageInterface?
|
||||
|
||||
@nonobjc
|
||||
private init(_ storage: StorageInterface?) {
|
||||
fileprivate init(_ storage: StorageInterface?) {
|
||||
|
||||
self.storageInterface = storage
|
||||
}
|
||||
|
||||
@@ -934,14 +934,14 @@ private func createFormattedString(_ firstLine: String, _ lastLine: String, _ in
|
||||
return string
|
||||
}
|
||||
|
||||
private extension String {
|
||||
fileprivate extension String {
|
||||
|
||||
private static func indention(_ level: Int = 1) -> String {
|
||||
fileprivate static func indention(_ level: Int = 1) -> String {
|
||||
|
||||
return String(repeating: Character(" "), count: level * 4)
|
||||
return String(repeating: " ", count: level * 4)
|
||||
}
|
||||
|
||||
private func trimSwiftModuleName() -> String {
|
||||
fileprivate func trimSwiftModuleName() -> String {
|
||||
|
||||
if self.hasPrefix("Swift.") {
|
||||
|
||||
@@ -950,12 +950,12 @@ private extension String {
|
||||
return self
|
||||
}
|
||||
|
||||
private mutating func indent(_ level: Int) {
|
||||
fileprivate mutating func indent(_ level: Int) {
|
||||
|
||||
self = self.replacingOccurrences(of: "\n", with: "\n\(String.indention(level))")
|
||||
}
|
||||
|
||||
private mutating func appendDumpInfo(_ key: String, _ value: Any) {
|
||||
fileprivate mutating func appendDumpInfo(_ key: String, _ value: Any) {
|
||||
|
||||
self.append("\n.\(key) = \(formattedValue(value));")
|
||||
}
|
||||
@@ -1071,7 +1071,7 @@ extension Bundle: CoreStoreDebugStringConvertible {
|
||||
|
||||
public var coreStoreDumpString: String {
|
||||
|
||||
return "\(self.bundleIdentifier.flatMap({ "\"\($0)\"" }) ?? "<unknown bundle identifier>") (\(self.bundleURL.lastPathComponent ?? "<unknown bundle URL>"))"
|
||||
return "\(self.bundleIdentifier.flatMap({ "\"\($0)\"" }) ?? "<unknown bundle identifier>") (\(self.bundleURL.lastPathComponent))"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public final class DefaultLogger: CoreStoreLogger {
|
||||
icon = "❗"
|
||||
levelString = "Fatal"
|
||||
}
|
||||
Swift.print("\(icon) [CoreStore: \(levelString)] \((String(fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
|
||||
Swift.print("\(icon) [CoreStore: \(levelString)] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public final class DefaultLogger: CoreStoreLogger {
|
||||
public func log(error: CoreStoreError, message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
|
||||
|
||||
#if DEBUG
|
||||
Swift.print("⚠️ [CoreStore: Error] \((String(fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n \(error)\n")
|
||||
Swift.print("⚠️ [CoreStore: Error] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n \(error)\n")
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public final class DefaultLogger: CoreStoreLogger {
|
||||
|
||||
return
|
||||
}
|
||||
Swift.print("❗ [CoreStore: Assertion Failure] \((String(fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message())\n")
|
||||
Swift.print("❗ [CoreStore: Assertion Failure] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message())\n")
|
||||
Swift.fatalError(file: fileName, line: UInt(lineNumber))
|
||||
#endif
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public final class DefaultLogger: CoreStoreLogger {
|
||||
*/
|
||||
public func abort(_ message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
|
||||
|
||||
Swift.print("❗ [CoreStore: Fatal Error] \((String(fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
|
||||
Swift.print("❗ [CoreStore: Fatal Error] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
|
||||
Swift.fatalError(file: fileName, line: UInt(lineNumber))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public extension CoreStore {
|
||||
- parameter storeType: the storage type
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
|
||||
*/
|
||||
public static func addStorage<T: StorageInterface>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) where T: DefaultInitializableStore {
|
||||
public static func addStorage<T: StorageInterface>(_ storeType: T.Type, completion: @escaping (SetupResult<T>) -> Void) where T: DefaultInitializableStore {
|
||||
|
||||
self.defaultStack.addStorage(storeType.init(), completion: completion)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public extension CoreStore {
|
||||
- parameter storage: the storage
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
|
||||
*/
|
||||
public static func addStorage<T: StorageInterface>(_ storage: T, completion: (SetupResult<T>) -> Void) {
|
||||
public static func addStorage<T: StorageInterface>(_ storage: T, completion: @escaping (SetupResult<T>) -> Void) {
|
||||
|
||||
self.defaultStack.addStorage(storage, completion: completion)
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public extension CoreStore {
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.success` 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: an `NSProgress` instance if a migration has started, or `nil` if either no migrations are required or if a failure occured.
|
||||
*/
|
||||
public static func addStorage<T: LocalStorage>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) -> Progress? where T: DefaultInitializableStore {
|
||||
public static func addStorage<T: LocalStorage>(_ storeType: T.Type, completion: @escaping (SetupResult<T>) -> Void) -> Progress? where T: DefaultInitializableStore {
|
||||
|
||||
return self.defaultStack.addStorage(storeType.init(), completion: completion)
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public extension CoreStore {
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.success` 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: an `NSProgress` instance if a migration has started, or `nil` if either no migrations are required or if a failure occured.
|
||||
*/
|
||||
public static func addStorage<T: LocalStorage>(_ storage: T, completion: (SetupResult<T>) -> Void) -> Progress? {
|
||||
public static func addStorage<T: LocalStorage>(_ storage: T, completion: @escaping (SetupResult<T>) -> Void) -> Progress? {
|
||||
|
||||
return self.defaultStack.addStorage(storage, completion: completion)
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public extension CoreStore {
|
||||
- parameter storage: the cloud storage
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `CloudStorage` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `CloudStorage` was already added at the same URL and with the same configuration.
|
||||
*/
|
||||
public static func addStorage<T: CloudStorage>(_ storage: T, completion: (SetupResult<T>) -> Void) {
|
||||
public static func addStorage<T: CloudStorage>(_ storage: T, completion: @escaping (SetupResult<T>) -> Void) {
|
||||
|
||||
self.defaultStack.addStorage(storage, completion: completion)
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public extension CoreStore {
|
||||
- throws: a `CoreStoreError` value indicating the failure
|
||||
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
|
||||
*/
|
||||
public static func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, completion: (MigrationResult) -> Void) throws -> Progress? {
|
||||
public static func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, completion: @escaping (MigrationResult) -> Void) throws -> Progress? {
|
||||
|
||||
return try self.defaultStack.upgradeStorageIfNeeded(storage, completion: completion)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public extension DataStack {
|
||||
- parameter storeType: the storage type
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
|
||||
*/
|
||||
public func addStorage<T: StorageInterface>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) where T: DefaultInitializableStore {
|
||||
public func addStorage<T: StorageInterface>(_ storeType: T.Type, completion: @escaping (SetupResult<T>) -> Void) where T: DefaultInitializableStore {
|
||||
|
||||
self.addStorage(storeType.init(), completion: completion)
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public extension DataStack {
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.success` 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: an `NSProgress` instance if a migration has started, or `nil` if either no migrations are required or if a failure occured.
|
||||
*/
|
||||
public func addStorage<T: LocalStorage>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) -> Progress? where T: DefaultInitializableStore {
|
||||
public func addStorage<T: LocalStorage>(_ storeType: T.Type, completion: @escaping (SetupResult<T>) -> Void) -> Progress? where T: DefaultInitializableStore {
|
||||
|
||||
return self.addStorage(storeType.init() as! T.Type, completion: completion)
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public extension DataStack {
|
||||
do {
|
||||
|
||||
try FileManager.default.createDirectory(
|
||||
at: try fileURL.deletingLastPathComponent(),
|
||||
at: fileURL.deletingLastPathComponent(),
|
||||
withIntermediateDirectories: true,
|
||||
attributes: nil
|
||||
)
|
||||
@@ -207,7 +207,7 @@ public extension DataStack {
|
||||
|
||||
return self.upgradeStorageIfNeeded(
|
||||
storage,
|
||||
metadata: metadata as [String : AnyObject],
|
||||
metadata: metadata,
|
||||
completion: { (result) -> Void in
|
||||
|
||||
if case .failure(.internalError(let error)) = result {
|
||||
@@ -359,7 +359,7 @@ public extension DataStack {
|
||||
do {
|
||||
|
||||
try FileManager.default.createDirectory(
|
||||
at: try cacheFileURL.deletingLastPathComponent(),
|
||||
at: cacheFileURL.deletingLastPathComponent(),
|
||||
withIntermediateDirectories: true,
|
||||
attributes: nil
|
||||
)
|
||||
@@ -431,7 +431,7 @@ public extension DataStack {
|
||||
- throws: a `CoreStoreError` value indicating the failure
|
||||
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
|
||||
*/
|
||||
public func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, completion: (MigrationResult) -> Void) throws -> Progress? {
|
||||
public func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, completion: @escaping (MigrationResult) -> Void) throws -> Progress? {
|
||||
|
||||
return try self.coordinator.performSynchronously {
|
||||
|
||||
@@ -450,7 +450,7 @@ public extension DataStack {
|
||||
)
|
||||
return self.upgradeStorageIfNeeded(
|
||||
storage,
|
||||
metadata: metadata as [String : AnyObject],
|
||||
metadata: metadata,
|
||||
completion: completion
|
||||
)
|
||||
}
|
||||
@@ -491,7 +491,7 @@ public extension DataStack {
|
||||
options: storage.storeOptions
|
||||
)
|
||||
|
||||
guard let migrationSteps = self.computeMigrationFromStorage(storage, metadata: metadata as [String : AnyObject]) else {
|
||||
guard let migrationSteps = self.computeMigrationFromStorage(storage, metadata: metadata) else {
|
||||
|
||||
let error = CoreStoreError.mappingModelNotFound(
|
||||
localStoreURL: fileURL,
|
||||
@@ -537,7 +537,7 @@ public extension DataStack {
|
||||
|
||||
// MARK: Private
|
||||
|
||||
private func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, metadata: [String: AnyObject], completion: @escaping (MigrationResult) -> Void) -> Progress? {
|
||||
private func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, metadata: [String: Any], completion: @escaping (MigrationResult) -> Void) -> Progress? {
|
||||
|
||||
guard let migrationSteps = self.computeMigrationFromStorage(storage, metadata: metadata) else {
|
||||
|
||||
@@ -654,7 +654,7 @@ public extension DataStack {
|
||||
return progress
|
||||
}
|
||||
|
||||
private func computeMigrationFromStorage<T: LocalStorage>(_ storage: T, metadata: [String: AnyObject]) -> [(sourceModel: NSManagedObjectModel, destinationModel: NSManagedObjectModel, mappingModel: NSMappingModel, migrationType: MigrationType)]? {
|
||||
private func computeMigrationFromStorage<T: LocalStorage>(_ storage: T, metadata: [String: Any]) -> [(sourceModel: NSManagedObjectModel, destinationModel: NSManagedObjectModel, mappingModel: NSMappingModel, migrationType: MigrationType)]? {
|
||||
|
||||
let model = self.model
|
||||
if model.isConfiguration(withName: storage.configuration, compatibleWithStoreMetadata: metadata) {
|
||||
@@ -737,7 +737,7 @@ public extension DataStack {
|
||||
|
||||
let fileURL = storage.fileURL
|
||||
|
||||
let temporaryDirectoryURL = try! URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
||||
let temporaryDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
||||
.appendingPathComponent(Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack")
|
||||
.appendingPathComponent(ProcessInfo().globallyUniqueString)
|
||||
|
||||
@@ -748,7 +748,7 @@ public extension DataStack {
|
||||
attributes: nil
|
||||
)
|
||||
|
||||
let temporaryFileURL = try! temporaryDirectoryURL.appendingPathComponent(
|
||||
let temporaryFileURL = temporaryDirectoryURL.appendingPathComponent(
|
||||
fileURL.lastPathComponent,
|
||||
isDirectory: false
|
||||
)
|
||||
|
||||
@@ -246,7 +246,7 @@ public struct MigrationChain: ExpressibleByNilLiteral, ExpressibleByStringLitera
|
||||
|
||||
// MARK: Private
|
||||
|
||||
private let versionTree: [String: String]
|
||||
fileprivate let versionTree: [String: String]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,11 +90,11 @@ public enum MigrationResult: Hashable {
|
||||
switch self {
|
||||
|
||||
case .success(let migrationTypes):
|
||||
return self.boolValue.hashValue
|
||||
return true.hashValue
|
||||
^ migrationTypes.map { $0.hashValue }.reduce(0, ^).hashValue
|
||||
|
||||
case .failure(let error):
|
||||
return self.boolValue.hashValue ^ error.hashValue
|
||||
return false.hashValue ^ error.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ public enum MigrationType: Hashable {
|
||||
|
||||
public var hashValue: Int {
|
||||
|
||||
let preHash = self.boolValue.hashValue ^ self.isHeavyweightMigration.hashValue
|
||||
let preHash = self.hasMigration.hashValue ^ self.isHeavyweightMigration.hashValue
|
||||
switch self {
|
||||
|
||||
case .none(let version):
|
||||
|
||||
@@ -93,10 +93,10 @@ public enum SetupResult<T: StorageInterface>: Hashable {
|
||||
switch self {
|
||||
|
||||
case .success(let storage):
|
||||
return self.boolValue.hashValue ^ ObjectIdentifier(storage).hashValue
|
||||
return true.hashValue ^ ObjectIdentifier(storage).hashValue
|
||||
|
||||
case .failure(let error):
|
||||
return self.boolValue.hashValue ^ error.hashValue
|
||||
return false.hashValue ^ error.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
self.bridgeToSwift.beginSynchronous { (transaction) in
|
||||
|
||||
closure(transaction: transaction.bridgeToObjectiveC)
|
||||
closure(transaction.bridgeToObjectiveC)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: a new `NSManagedObject` instance of the specified entity type.
|
||||
*/
|
||||
@objc
|
||||
public override func createInto(_ into: CSInto) -> AnyObject {
|
||||
public override func createInto(_ into: CSInto) -> Any {
|
||||
|
||||
return self.bridgeToSwift.create(into.bridgeToSwift)
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
public override func editObject(_ object: NSManagedObject?) -> AnyObject? {
|
||||
public override func editObject(_ object: NSManagedObject?) -> Any? {
|
||||
|
||||
return self.bridgeToSwift.edit(object)
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> Any? {
|
||||
|
||||
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public extension CSBaseDataTransaction {
|
||||
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
|
||||
*/
|
||||
@objc
|
||||
public func fetchExistingObject(_ object: NSManagedObject) -> AnyObject? {
|
||||
public func fetchExistingObject(_ object: NSManagedObject) -> Any? {
|
||||
|
||||
do {
|
||||
|
||||
@@ -57,7 +57,7 @@ public extension CSBaseDataTransaction {
|
||||
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
|
||||
*/
|
||||
@objc
|
||||
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
|
||||
|
||||
do {
|
||||
|
||||
@@ -76,7 +76,7 @@ public extension CSBaseDataTransaction {
|
||||
- returns: the `NSManagedObject` array for objects that exists in the transaction
|
||||
*/
|
||||
@objc
|
||||
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [AnyObject] {
|
||||
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
|
||||
|
||||
return objects.flatMap { try? self.bridgeToSwift.context.existingObject(with: $0.objectID) }
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public extension CSBaseDataTransaction {
|
||||
- returns: the `NSManagedObject` array for objects that exists in the transaction
|
||||
*/
|
||||
@objc
|
||||
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [AnyObject] {
|
||||
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
|
||||
|
||||
return objectIDs.flatMap { try? self.bridgeToSwift.context.existingObject(with: $0) }
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public extension CSBaseDataTransaction {
|
||||
- returns: the first `NSManagedObject` instance that satisfies the specified `CSFetchClause`s
|
||||
*/
|
||||
@objc
|
||||
public func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
|
||||
public func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> Any? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.bridgeToSwift.isRunningInAllowedQueue(),
|
||||
@@ -118,7 +118,7 @@ public extension CSBaseDataTransaction {
|
||||
- returns: all `NSManagedObject` instances that satisfy the specified `CSFetchClause`s
|
||||
*/
|
||||
@objc
|
||||
public func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
|
||||
public func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [Any]? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.bridgeToSwift.isRunningInAllowedQueue(),
|
||||
@@ -141,7 +141,9 @@ public extension CSBaseDataTransaction {
|
||||
self.bridgeToSwift.isRunningInAllowedQueue(),
|
||||
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
return self.bridgeToSwift.context.fetchCount(from, fetchClauses)
|
||||
return self.bridgeToSwift.context
|
||||
.fetchCount(from, fetchClauses)
|
||||
.flatMap { NSNumber(value: $0) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,7 +174,7 @@ public extension CSBaseDataTransaction {
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
|
||||
*/
|
||||
@objc
|
||||
public func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
public func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> Any? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.bridgeToSwift.isRunningInAllowedQueue(),
|
||||
@@ -192,7 +194,7 @@ public extension CSBaseDataTransaction {
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
|
||||
*/
|
||||
@objc
|
||||
public func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
public func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[String: Any]]? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.bridgeToSwift.isRunningInAllowedQueue(),
|
||||
|
||||
@@ -55,7 +55,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a new `NSManagedObject` instance of the specified entity type.
|
||||
*/
|
||||
@objc
|
||||
public func createInto(_ into: CSInto) -> AnyObject {
|
||||
public func createInto(_ into: CSInto) -> Any {
|
||||
|
||||
return self.bridgeToSwift.create(into.bridgeToSwift)
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
public func editObject(_ object: NSManagedObject?) -> AnyObject? {
|
||||
public func editObject(_ object: NSManagedObject?) -> Any? {
|
||||
|
||||
return self.bridgeToSwift.edit(object)
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
public func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> Any? {
|
||||
|
||||
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public extension CSCoreStore {
|
||||
- parameter storage: the `CSInMemoryStore` instance
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `CSSetupResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously.
|
||||
*/
|
||||
public static func addInMemoryStorage(_ storage: CSInMemoryStore, completion: (CSSetupResult) -> Void) {
|
||||
public static func addInMemoryStorage(_ storage: CSInMemoryStore, completion: @escaping (CSSetupResult) -> Void) {
|
||||
|
||||
self.defaultStack.addInMemoryStorage(storage, completion: completion)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public extension CSCoreStore {
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
public static func addSQLiteStorage(_ storage: CSSQLiteStore, completion: (CSSetupResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
public static func addSQLiteStorage(_ storage: CSSQLiteStore, completion: @escaping (CSSetupResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
|
||||
return self.defaultStack.addSQLiteStorage(storage, completion: completion, error: error)
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public extension CSCoreStore {
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
@objc
|
||||
public static func upgradeStorageIfNeeded(_ storage: CSSQLiteStore, completion: (CSMigrationResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
public static func upgradeStorageIfNeeded(_ storage: CSSQLiteStore, completion: @escaping (CSMigrationResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
|
||||
return self.defaultStack.upgradeStorageIfNeeded(storage, completion: completion, error: error)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public extension CSCoreStore {
|
||||
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
|
||||
*/
|
||||
@objc
|
||||
public static func monitorListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
|
||||
public static func monitorListByCreatingAsynchronously(_ createAsynchronously: @escaping (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
|
||||
|
||||
return self.defaultStack.monitorListByCreatingAsynchronously(
|
||||
createAsynchronously,
|
||||
@@ -102,7 +102,7 @@ public extension CSCoreStore {
|
||||
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
|
||||
*/
|
||||
@objc
|
||||
public static func monitorSectionedListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
|
||||
public static func monitorSectionedListByCreatingAsynchronously(_ createAsynchronously: @escaping (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
|
||||
|
||||
self.defaultStack.monitorSectionedListByCreatingAsynchronously(
|
||||
createAsynchronously,
|
||||
|
||||
@@ -38,7 +38,7 @@ public extension CSCoreStore {
|
||||
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
|
||||
*/
|
||||
@objc
|
||||
public static func fetchExistingObject(_ object: NSManagedObject) -> AnyObject? {
|
||||
public static func fetchExistingObject(_ object: NSManagedObject) -> Any? {
|
||||
|
||||
return self.defaultStack.fetchExistingObject(object)
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public extension CSCoreStore {
|
||||
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
|
||||
*/
|
||||
@objc
|
||||
public static func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public static func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
|
||||
|
||||
return self.defaultStack.fetchExistingObjectWithID(objectID)
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public extension CSCoreStore {
|
||||
- returns: the `NSManagedObject` array for objects that exists in the transaction
|
||||
*/
|
||||
@objc
|
||||
public static func fetchExistingObjects(_ objects: [NSManagedObject]) -> [AnyObject] {
|
||||
public static func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
|
||||
|
||||
return self.defaultStack.fetchExistingObjects(objects)
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public extension CSCoreStore {
|
||||
- returns: the `NSManagedObject` array for objects that exists in the transaction
|
||||
*/
|
||||
@objc
|
||||
public static func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [AnyObject] {
|
||||
public static func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
|
||||
|
||||
return self.defaultStack.fetchExistingObjectsWithIDs(objectIDs)
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public extension CSCoreStore {
|
||||
- returns: the first `NSManagedObject` instance that satisfies the specified `CSFetchClause`s
|
||||
*/
|
||||
@objc
|
||||
public static func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
|
||||
public static func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> Any? {
|
||||
|
||||
return self.defaultStack.fetchOneFrom(from, fetchClauses: fetchClauses)
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public extension CSCoreStore {
|
||||
- returns: all `NSManagedObject` instances that satisfy the specified `CSFetchClause`s
|
||||
*/
|
||||
@objc
|
||||
public static func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
|
||||
public static func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [Any]? {
|
||||
|
||||
return self.defaultStack.fetchAllFrom(from, fetchClauses: fetchClauses)
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public extension CSCoreStore {
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
|
||||
*/
|
||||
@objc
|
||||
public static func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
public static func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> Any? {
|
||||
|
||||
return self.defaultStack.queryValueFrom(from, selectClause: selectClause, queryClauses: queryClauses)
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public extension CSCoreStore {
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
|
||||
*/
|
||||
@objc
|
||||
public static func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
public static func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[String: Any]]? {
|
||||
|
||||
return self.defaultStack.queryAttributesFrom(from, selectClause: selectClause, queryClauses: queryClauses)
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public extension CSCoreStore {
|
||||
|
||||
CoreStore.beginSynchronous { (transaction) in
|
||||
|
||||
closure(transaction: transaction.bridgeToObjectiveC)
|
||||
closure(transaction.bridgeToObjectiveC)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public extension CSDataStack {
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `CSSetupResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously.
|
||||
*/
|
||||
@objc
|
||||
public func addInMemoryStorage(_ storage: CSInMemoryStore, completion: (CSSetupResult) -> Void) {
|
||||
public func addInMemoryStorage(_ storage: CSInMemoryStore, completion: @escaping (CSSetupResult) -> Void) {
|
||||
|
||||
self.bridgeToSwift.addStorage(
|
||||
storage.bridgeToSwift,
|
||||
@@ -77,7 +77,7 @@ public extension CSDataStack {
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
@objc
|
||||
public func addSQLiteStorage(_ storage: CSSQLiteStore, completion: (CSSetupResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
public func addSQLiteStorage(_ storage: CSSQLiteStore, completion: @escaping (CSSetupResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
|
||||
return bridge(error) {
|
||||
|
||||
@@ -97,7 +97,7 @@ public extension CSDataStack {
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
@objc
|
||||
public func upgradeStorageIfNeeded(_ storage: CSSQLiteStore, completion: (CSMigrationResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
public func upgradeStorageIfNeeded(_ storage: CSSQLiteStore, completion: @escaping (CSMigrationResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
|
||||
return bridge(error) {
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public extension CSDataStack {
|
||||
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
|
||||
*/
|
||||
@objc
|
||||
public func monitorListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
|
||||
public func monitorListByCreatingAsynchronously(_ createAsynchronously: @escaping (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
|
||||
|
||||
CoreStore.assert(
|
||||
Thread.isMainThread,
|
||||
@@ -154,7 +154,7 @@ public extension CSDataStack {
|
||||
- parameter sectionBy: a `CSSectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
|
||||
*/
|
||||
public func monitorSectionedListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
|
||||
public func monitorSectionedListByCreatingAsynchronously(_ createAsynchronously: @escaping (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
|
||||
|
||||
CoreStore.assert(
|
||||
Thread.isMainThread,
|
||||
|
||||
@@ -38,7 +38,7 @@ public extension CSDataStack {
|
||||
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
|
||||
*/
|
||||
@objc
|
||||
public func fetchExistingObject(_ object: NSManagedObject) -> AnyObject? {
|
||||
public func fetchExistingObject(_ object: NSManagedObject) -> Any? {
|
||||
|
||||
do {
|
||||
|
||||
@@ -57,7 +57,7 @@ public extension CSDataStack {
|
||||
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
|
||||
*/
|
||||
@objc
|
||||
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
|
||||
|
||||
do {
|
||||
|
||||
@@ -76,7 +76,7 @@ public extension CSDataStack {
|
||||
- returns: the `NSManagedObject` array for objects that exists in the transaction
|
||||
*/
|
||||
@objc
|
||||
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [AnyObject] {
|
||||
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
|
||||
|
||||
return objects.flatMap { try? self.bridgeToSwift.mainContext.existingObject(with: $0.objectID) }
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public extension CSDataStack {
|
||||
- returns: the `NSManagedObject` array for objects that exists in the transaction
|
||||
*/
|
||||
@objc
|
||||
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [AnyObject] {
|
||||
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
|
||||
|
||||
return objectIDs.flatMap { try? self.bridgeToSwift.mainContext.existingObject(with: $0) }
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public extension CSDataStack {
|
||||
- returns: the first `NSManagedObject` instance that satisfies the specified `CSFetchClause`s
|
||||
*/
|
||||
@objc
|
||||
public func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
|
||||
public func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> Any? {
|
||||
|
||||
CoreStore.assert(
|
||||
Thread.isMainThread,
|
||||
@@ -118,7 +118,7 @@ public extension CSDataStack {
|
||||
- returns: all `NSManagedObject` instances that satisfy the specified `CSFetchClause`s
|
||||
*/
|
||||
@objc
|
||||
public func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
|
||||
public func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [Any]? {
|
||||
|
||||
CoreStore.assert(
|
||||
Thread.isMainThread,
|
||||
@@ -141,7 +141,9 @@ public extension CSDataStack {
|
||||
Thread.isMainThread,
|
||||
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
return self.bridgeToSwift.mainContext.fetchCount(from, fetchClauses)
|
||||
return self.bridgeToSwift.mainContext
|
||||
.fetchCount(from, fetchClauses)
|
||||
.flatMap { NSNumber(value: $0) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +191,7 @@ public extension CSDataStack {
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
|
||||
*/
|
||||
@objc
|
||||
public func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
public func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> Any? {
|
||||
|
||||
CoreStore.assert(
|
||||
Thread.isMainThread,
|
||||
@@ -209,7 +211,7 @@ public extension CSDataStack {
|
||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
|
||||
*/
|
||||
@objc
|
||||
public func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
public func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[String: Any]]? {
|
||||
|
||||
CoreStore.assert(
|
||||
Thread.isMainThread,
|
||||
|
||||
@@ -58,7 +58,7 @@ public extension CSDataStack {
|
||||
|
||||
self.bridgeToSwift.beginSynchronous { (transaction) in
|
||||
|
||||
closure(transaction: transaction.bridgeToObjectiveC)
|
||||
closure(transaction.bridgeToObjectiveC)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
|
||||
self.swiftError = swiftValue
|
||||
|
||||
let code: CoreStoreErrorCode
|
||||
let info: [NSObject: AnyObject]
|
||||
let info: [AnyHashable: Any]
|
||||
switch swiftValue {
|
||||
|
||||
case .unknown:
|
||||
@@ -150,27 +150,27 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
|
||||
case .differentStorageExistsAtURL(let existingPersistentStoreURL):
|
||||
code = .differentStorageExistsAtURL
|
||||
info = [
|
||||
"existingPersistentStoreURL" as NSObject: existingPersistentStoreURL as AnyObject
|
||||
"existingPersistentStoreURL": existingPersistentStoreURL
|
||||
]
|
||||
|
||||
case .mappingModelNotFound(let localStoreURL, let targetModel, let targetModelVersion):
|
||||
code = .mappingModelNotFound
|
||||
info = [
|
||||
"localStoreURL" as NSObject: localStoreURL as AnyObject,
|
||||
"targetModel" as NSObject: targetModel,
|
||||
"targetModelVersion" as NSObject: targetModelVersion as AnyObject
|
||||
"localStoreURL": localStoreURL,
|
||||
"targetModel": targetModel,
|
||||
"targetModelVersion": targetModelVersion
|
||||
]
|
||||
|
||||
case .progressiveMigrationRequired(let localStoreURL):
|
||||
code = .progressiveMigrationRequired
|
||||
info = [
|
||||
"localStoreURL" as NSObject: localStoreURL as AnyObject
|
||||
"localStoreURL": localStoreURL
|
||||
]
|
||||
|
||||
case .internalError(let NSError):
|
||||
code = .internalError
|
||||
info = [
|
||||
"NSError" as NSObject: NSError
|
||||
"NSError": NSError
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class CSFrom: NSObject, CoreStoreObjectiveCType {
|
||||
May contain `NSString` instances to pertain to named configurations, or `NSNull` to pertain to the default configuration
|
||||
*/
|
||||
@objc
|
||||
public var configurations: [AnyObject]? {
|
||||
public var configurations: [Any]? {
|
||||
|
||||
return self.bridgeToSwift.configurations?.map {
|
||||
|
||||
@@ -85,7 +85,7 @@ public final class CSFrom: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter configuration: the `NSPersistentStore` configuration name to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject`'s entity type. Set to `[NSNull null]` to use the default configuration.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(entityClass: AnyClass, configuration: AnyObject) {
|
||||
public convenience init(entityClass: AnyClass, configuration: Any) {
|
||||
|
||||
switch configuration {
|
||||
|
||||
@@ -111,7 +111,7 @@ public final class CSFrom: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter configurations: an array of the `NSPersistentStore` configuration names to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject`'s entity type. Set to `[NSNull null]` to use the default configuration.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(entityClass: AnyClass, configurations: [AnyObject]) {
|
||||
public convenience init(entityClass: AnyClass, configurations: [Any]) {
|
||||
|
||||
var arguments = [String?]()
|
||||
for configuration in configurations {
|
||||
|
||||
@@ -79,7 +79,7 @@ public final class CSInMemoryStore: NSObject, CSStorageInterface, CoreStoreObjec
|
||||
The options dictionary for the `NSPersistentStore`. For `CSInMemoryStore`s, this is always set to `nil`.
|
||||
*/
|
||||
@objc
|
||||
public var storeOptions: [String: AnyObject]? {
|
||||
public var storeOptions: [AnyHashable: Any]? {
|
||||
|
||||
return self.bridgeToSwift.storeOptions
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` at the specified index
|
||||
*/
|
||||
@objc
|
||||
public subscript(index: Int) -> AnyObject {
|
||||
public subscript(index: Int) -> Any {
|
||||
|
||||
return self.bridgeToSwift[index]
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` at the specified index, or `nil` if out of bounds
|
||||
*/
|
||||
@objc
|
||||
public func objectAtSafeIndex(_ index: Int) -> AnyObject? {
|
||||
public func objectAtSafeIndex(_ index: Int) -> Any? {
|
||||
|
||||
return self.bridgeToSwift[safeIndex: index]
|
||||
}
|
||||
@@ -73,12 +73,10 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` at the specified section and item index
|
||||
*/
|
||||
@objc
|
||||
public func objectAtSectionIndex(_ sectionIndex: Int, itemIndex: Int) -> AnyObject {
|
||||
public func objectAtSectionIndex(_ sectionIndex: Int, itemIndex: Int) -> Any {
|
||||
|
||||
return self.bridgeToSwift[sectionIndex, itemIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
} /**
|
||||
Returns the object at the given section and item index, or `nil` if out of bounds. This indexer is typically used for `CSListMonitor`s created as sectioned lists.
|
||||
|
||||
- parameter sectionIndex: the section index for the object. Using a `sectionIndex` with an invalid range will return `nil`.
|
||||
@@ -86,7 +84,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` at the specified section and item index, or `nil` if out of bounds
|
||||
*/
|
||||
@objc
|
||||
public func objectAtSafeSectionIndex(_ sectionIndex: Int, safeItemIndex itemIndex: Int) -> AnyObject? {
|
||||
public func objectAtSafeSectionIndex(_ sectionIndex: Int, safeItemIndex itemIndex: Int) -> Any? {
|
||||
|
||||
return self.bridgeToSwift[safeSectionIndex: sectionIndex, safeItemIndex: itemIndex]
|
||||
}
|
||||
@@ -98,7 +96,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` at the specified index path
|
||||
*/
|
||||
@objc
|
||||
public func objectAtIndexPath(_ indexPath: IndexPath) -> AnyObject {
|
||||
public func objectAtIndexPath(_ indexPath: IndexPath) -> Any {
|
||||
|
||||
return self.bridgeToSwift[indexPath]
|
||||
}
|
||||
@@ -110,7 +108,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` at the specified index path, or `nil` if out of bounds
|
||||
*/
|
||||
@objc
|
||||
public func objectAtSafeIndexPath(_ indexPath: IndexPath) -> AnyObject? {
|
||||
public func objectAtSafeIndexPath(_ indexPath: IndexPath) -> Any? {
|
||||
|
||||
return self.bridgeToSwift[safeIndexPath: indexPath]
|
||||
}
|
||||
@@ -216,7 +214,9 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public func numberOfObjectsInSafeSection(safeSectionIndex section: Int) -> NSNumber? {
|
||||
|
||||
return self.bridgeToSwift.numberOfObjectsInSection(safeSectionIndex: section)
|
||||
return self.bridgeToSwift
|
||||
.numberOfObjectsInSection(safeSectionIndex: section)
|
||||
.flatMap { NSNumber(value: $0) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,7 +287,9 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public func indexOf(_ object: NSManagedObject) -> NSNumber? {
|
||||
|
||||
return self.bridgeToSwift.indexOf(object)
|
||||
return self.bridgeToSwift
|
||||
.indexOf(object)
|
||||
.flatMap { NSNumber(value: $0) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -103,7 +103,7 @@ public protocol CSListObjectObserver: CSListObserver {
|
||||
- parameter indexPath: the new `NSIndexPath` for the inserted object
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didInsertObject object: AnyObject, toIndexPath indexPath: IndexPath)
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didInsertObject object: Any, toIndexPath indexPath: IndexPath)
|
||||
|
||||
/**
|
||||
Notifies that an object was deleted from the specified `NSIndexPath` in the list
|
||||
@@ -113,7 +113,7 @@ public protocol CSListObjectObserver: CSListObserver {
|
||||
- parameter indexPath: the `NSIndexPath` for the deleted object
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didDeleteObject object: AnyObject, fromIndexPath indexPath: IndexPath)
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didDeleteObject object: Any, fromIndexPath indexPath: IndexPath)
|
||||
|
||||
/**
|
||||
Notifies that an object at the specified `NSIndexPath` was updated
|
||||
@@ -123,7 +123,7 @@ public protocol CSListObjectObserver: CSListObserver {
|
||||
- parameter indexPath: the `NSIndexPath` for the updated object
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didUpdateObject object: AnyObject, atIndexPath indexPath: IndexPath)
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didUpdateObject object: Any, atIndexPath indexPath: IndexPath)
|
||||
|
||||
/**
|
||||
Notifies that an object's index changed
|
||||
@@ -134,7 +134,7 @@ public protocol CSListObjectObserver: CSListObserver {
|
||||
- parameter toIndexPath: the new `NSIndexPath` for the moved object
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didMoveObject object: AnyObject, fromIndexPath: IndexPath, toIndexPath: IndexPath)
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didMoveObject object: Any, fromIndexPath: IndexPath, toIndexPath: IndexPath)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public var isSuccess: Bool {
|
||||
|
||||
return self.bridgeToSwift.boolValue
|
||||
return self.bridgeToSwift.isSuccess
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public var isFailure: Bool {
|
||||
|
||||
return !self.bridgeToSwift.boolValue
|
||||
return !self.bridgeToSwift.isSuccess
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class CSMigrationType: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public var needsMigration: Bool {
|
||||
|
||||
return self.bridgeToSwift.boolValue
|
||||
return self.bridgeToSwift.hasMigration
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class CSObjectMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
/**
|
||||
Returns the `NSManagedObject` instance being observed, or `nil` if the object was already deleted.
|
||||
*/
|
||||
public var object: AnyObject? {
|
||||
public var object: Any? {
|
||||
|
||||
return self.bridgeToSwift.object
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public protocol CSObjectObserver: class, AnyObject {
|
||||
- parameter object: the `NSManagedObject` instance being observed
|
||||
*/
|
||||
@objc
|
||||
optional func objectMonitor(_ monitor: CSObjectMonitor, willUpdateObject object: AnyObject)
|
||||
optional func objectMonitor(_ monitor: CSObjectMonitor, willUpdateObject object: Any)
|
||||
|
||||
/**
|
||||
Handles processing right after a change to the observed `object` occurs
|
||||
@@ -60,7 +60,7 @@ public protocol CSObjectObserver: class, AnyObject {
|
||||
- parameter changedPersistentKeys: an `NSSet` of key paths for the attributes that were changed. Note that `changedPersistentKeys` only contains keys for attributes/relationships present in the persistent store, thus transient properties will not be reported.
|
||||
*/
|
||||
@objc
|
||||
optional func objectMonitor(_ monitor: CSObjectMonitor, didUpdateObject object: AnyObject, changedPersistentKeys: Set<String>)
|
||||
optional func objectMonitor(_ monitor: CSObjectMonitor, didUpdateObject object: Any, changedPersistentKeys: Set<String>)
|
||||
|
||||
/**
|
||||
Handles processing right after `object` is deleted
|
||||
@@ -69,7 +69,7 @@ public protocol CSObjectObserver: class, AnyObject {
|
||||
- parameter object: the `NSManagedObject` instance being observed
|
||||
*/
|
||||
@objc
|
||||
optional func objectMonitor(_ monitor: CSObjectMonitor, didDeleteObject object: AnyObject)
|
||||
optional func objectMonitor(_ monitor: CSObjectMonitor, didDeleteObject object: Any)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
|
||||
The list of sort descriptors
|
||||
*/
|
||||
@objc
|
||||
public var sortDescriptors: [SortDescriptor] {
|
||||
public var sortDescriptors: [NSSortDescriptor] {
|
||||
|
||||
return self.bridgeToSwift.sortDescriptors
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
|
||||
- parameter sortDescriptor: a `NSSortDescriptor`
|
||||
*/
|
||||
@objc
|
||||
public convenience init(sortDescriptor: SortDescriptor) {
|
||||
public convenience init(sortDescriptor: NSSortDescriptor) {
|
||||
|
||||
self.init(OrderBy(sortDescriptor))
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
|
||||
- parameter sortDescriptors: an array of `NSSortDescriptor`s
|
||||
*/
|
||||
@objc
|
||||
public convenience init(sortDescriptors: [SortDescriptor]) {
|
||||
public convenience init(sortDescriptors: [NSSortDescriptor]) {
|
||||
|
||||
self.init(OrderBy(sortDescriptors))
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCT
|
||||
```
|
||||
*/
|
||||
@objc
|
||||
public var storeOptions: [String: AnyObject]? {
|
||||
public var storeOptions: [AnyHashable: Any]? {
|
||||
|
||||
return self.bridgeToSwift.storeOptions
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a `CSSectionBy` clause with the key path to use to group `CSListMonitor` objects into sections
|
||||
*/
|
||||
@objc
|
||||
public static func keyPath(_ sectionKeyPath: KeyPath, sectionIndexTransformer: (_ sectionName: String?) -> String?) -> CSSectionBy {
|
||||
public static func keyPath(_ sectionKeyPath: KeyPath, sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> CSSectionBy {
|
||||
|
||||
return self.init(SectionBy(sectionKeyPath, sectionIndexTransformer))
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public static func average(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
|
||||
|
||||
return self.init(.average(keyPath, As: alias))
|
||||
return self.init(.average(keyPath, as: alias))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public static func count(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
|
||||
|
||||
return self.init(.count(keyPath, As: alias))
|
||||
return self.init(.count(keyPath, as: alias))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public static func maximum(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
|
||||
|
||||
return self.init(.maximum(keyPath, As: alias))
|
||||
return self.init(.maximum(keyPath, as: alias))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public static func minimum(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
|
||||
|
||||
return self.init(.minimum(keyPath, As: alias))
|
||||
return self.init(.minimum(keyPath, as: alias))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +135,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public static func sum(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
|
||||
|
||||
return self.init(.sum(keyPath, As: alias))
|
||||
return self.init(.sum(keyPath, as: alias))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +153,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public static func objectIDAs(_ alias: KeyPath? = nil) -> CSSelectTerm {
|
||||
|
||||
return self.init(.objectID(As: alias))
|
||||
return self.init(.objectID(as: alias))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public protocol CSStorageInterface {
|
||||
The options dictionary for the `NSPersistentStore`
|
||||
*/
|
||||
@objc
|
||||
var storeOptions: [String: AnyObject]? { get }
|
||||
var storeOptions: [AnyHashable: Any]? { get }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
self.bridgeToSwift.beginSynchronous { (transaction) in
|
||||
|
||||
closure(transaction: transaction.bridgeToObjectiveC)
|
||||
closure(transaction.bridgeToObjectiveC)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: a new `NSManagedObject` instance of the specified entity type.
|
||||
*/
|
||||
@objc
|
||||
public override func createInto(_ into: CSInto) -> AnyObject {
|
||||
public override func createInto(_ into: CSInto) -> Any {
|
||||
|
||||
return self.bridgeToSwift.create(into.bridgeToSwift)
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
public override func editObject(_ object: NSManagedObject?) -> AnyObject? {
|
||||
public override func editObject(_ object: NSManagedObject?) -> Any? {
|
||||
|
||||
return self.bridgeToSwift.edit(object)
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> Any? {
|
||||
|
||||
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public final class CSTweak: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
- parameter block: the block to customize the `NSFetchRequest`
|
||||
*/
|
||||
@objc
|
||||
public convenience init(block: (_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> Void) {
|
||||
public convenience init(block: @escaping (_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> Void) {
|
||||
|
||||
self.init(Tweak(block))
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
The internal `NSPredicate` instance for the `Where` clause
|
||||
*/
|
||||
@objc
|
||||
public var predicate: Predicate {
|
||||
public var predicate: NSPredicate {
|
||||
|
||||
return self.bridgeToSwift.predicate
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
- parameter predicate: the `NSPredicate` for the fetch or query
|
||||
*/
|
||||
@objc
|
||||
public convenience init(predicate: Predicate) {
|
||||
public convenience init(predicate: NSPredicate) {
|
||||
|
||||
self.init(Where(predicate))
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public extension NSManagedObject {
|
||||
- returns: the primitive value for the KVC key
|
||||
*/
|
||||
@objc
|
||||
public func cs_accessValueForKVCKey(_ KVCKey: KeyPath) -> AnyObject? {
|
||||
public func cs_accessValueForKVCKey(_ KVCKey: KeyPath) -> Any? {
|
||||
|
||||
return self.accessValueForKVCKey(KVCKey)
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public extension NSManagedObject {
|
||||
- parameter KVCKey: the KVC key
|
||||
*/
|
||||
@objc
|
||||
public func cs_setValue(_ value: AnyObject?, forKVCKey KVCKey: KeyPath) {
|
||||
public func cs_setValue(_ value: Any?, forKVCKey KVCKey: KeyPath) {
|
||||
|
||||
self.setValue(value, forKVCKey: KVCKey)
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ internal extension NSManagedObjectContext {
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func queryValue(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
internal func queryValue(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> Any? {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest<NSFetchRequestResult>()
|
||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||
@@ -154,7 +154,7 @@ internal extension NSManagedObjectContext {
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func queryAttributes(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
internal func queryAttributes(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> [[String: Any]]? {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest<NSFetchRequestResult>()
|
||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||
|
||||
@@ -75,7 +75,7 @@ public extension CoreStore {
|
||||
- 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.
|
||||
*/
|
||||
public static func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
|
||||
public static func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
|
||||
|
||||
self.defaultStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public extension CoreStore {
|
||||
- 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.
|
||||
*/
|
||||
public static func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
|
||||
public static func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
|
||||
|
||||
self.defaultStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public extension CoreStore {
|
||||
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||
*/
|
||||
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
|
||||
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
|
||||
|
||||
self.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public extension CoreStore {
|
||||
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||
*/
|
||||
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
|
||||
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
|
||||
|
||||
self.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public extension DataStack {
|
||||
- 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.
|
||||
*/
|
||||
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
|
||||
public func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
|
||||
|
||||
self.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public extension DataStack {
|
||||
- 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.
|
||||
*/
|
||||
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
|
||||
public func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
|
||||
|
||||
CoreStore.assert(
|
||||
Thread.isMainThread,
|
||||
@@ -183,7 +183,7 @@ public extension DataStack {
|
||||
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||
*/
|
||||
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
|
||||
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
|
||||
|
||||
self.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public extension DataStack {
|
||||
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||
*/
|
||||
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
|
||||
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
|
||||
|
||||
CoreStore.assert(
|
||||
Thread.isMainThread,
|
||||
|
||||
@@ -604,7 +604,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
||||
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
||||
|
||||
self.init(
|
||||
context: dataStack.mainContext,
|
||||
@@ -616,7 +616,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
)
|
||||
}
|
||||
|
||||
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: (ListMonitor<T>) -> Void) {
|
||||
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: @escaping (ListMonitor<T>) -> Void) {
|
||||
|
||||
self.init(
|
||||
context: dataStack.mainContext,
|
||||
@@ -628,7 +628,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
)
|
||||
}
|
||||
|
||||
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
||||
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
||||
|
||||
self.init(
|
||||
context: unsafeTransaction.context,
|
||||
@@ -640,7 +640,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
)
|
||||
}
|
||||
|
||||
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: (ListMonitor<T>) -> Void) {
|
||||
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: @escaping (ListMonitor<T>) -> Void) {
|
||||
|
||||
self.init(
|
||||
context: unsafeTransaction.context,
|
||||
@@ -687,15 +687,15 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
guard let `self` = self,
|
||||
let userInfo = note.userInfo,
|
||||
let object = userInfo[String(NSManagedObject.self)] as? T else {
|
||||
let object = userInfo[String(describing: NSManagedObject.self)] as? T else {
|
||||
|
||||
return
|
||||
}
|
||||
callback(
|
||||
self,
|
||||
object,
|
||||
userInfo[String(IndexPath.self)] as? IndexPath,
|
||||
userInfo["\(String(IndexPath.self)).New"] as? IndexPath
|
||||
userInfo[String(describing: IndexPath.self)] as? IndexPath,
|
||||
userInfo["\(String(describing: IndexPath.self)).New"] as? IndexPath
|
||||
)
|
||||
}
|
||||
),
|
||||
@@ -714,8 +714,8 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
guard let `self` = self,
|
||||
let userInfo = note.userInfo,
|
||||
let sectionInfo = userInfo[String(NSFetchedResultsSectionInfo.self)] as? NSFetchedResultsSectionInfo,
|
||||
let sectionIndex = (userInfo[String(NSNumber.self)] as? NSNumber)?.intValue else {
|
||||
let sectionInfo = userInfo[String(describing: NSFetchedResultsSectionInfo.self)] as? NSFetchedResultsSectionInfo,
|
||||
let sectionIndex = (userInfo[String(describing: NSNumber.self)] as? NSNumber)?.intValue else {
|
||||
|
||||
return
|
||||
}
|
||||
@@ -743,7 +743,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
return
|
||||
}
|
||||
willChange(observer: observer, monitor: monitor)
|
||||
willChange(observer, monitor)
|
||||
}
|
||||
)
|
||||
self.registerChangeNotification(
|
||||
@@ -756,7 +756,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
return
|
||||
}
|
||||
didChange(observer: observer, monitor: monitor)
|
||||
didChange(observer, monitor)
|
||||
}
|
||||
)
|
||||
self.registerChangeNotification(
|
||||
@@ -769,7 +769,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
return
|
||||
}
|
||||
willRefetch(observer: observer, monitor: monitor)
|
||||
willRefetch(observer, monitor)
|
||||
}
|
||||
)
|
||||
self.registerChangeNotification(
|
||||
@@ -782,7 +782,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
return
|
||||
}
|
||||
didRefetch(observer: observer, monitor: monitor)
|
||||
didRefetch(observer, monitor)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -804,12 +804,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
return
|
||||
}
|
||||
didInsertObject(
|
||||
observer: observer,
|
||||
monitor: monitor,
|
||||
object: object,
|
||||
toIndexPath: newIndexPath!
|
||||
)
|
||||
didInsertObject(observer, monitor, object, newIndexPath!)
|
||||
}
|
||||
)
|
||||
self.registerObjectNotification(
|
||||
@@ -822,12 +817,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
return
|
||||
}
|
||||
didDeleteObject(
|
||||
observer: observer,
|
||||
monitor: monitor,
|
||||
object: object,
|
||||
fromIndexPath: indexPath!
|
||||
)
|
||||
didDeleteObject(observer, monitor, object, indexPath!)
|
||||
}
|
||||
)
|
||||
self.registerObjectNotification(
|
||||
@@ -840,12 +830,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
return
|
||||
}
|
||||
didUpdateObject(
|
||||
observer: observer,
|
||||
monitor: monitor,
|
||||
object: object,
|
||||
atIndexPath: indexPath!
|
||||
)
|
||||
didUpdateObject(observer, monitor, object, indexPath!)
|
||||
}
|
||||
)
|
||||
self.registerObjectNotification(
|
||||
@@ -858,13 +843,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
return
|
||||
}
|
||||
didMoveObject(
|
||||
observer: observer,
|
||||
monitor: monitor,
|
||||
object: object,
|
||||
fromIndexPath: indexPath!,
|
||||
toIndexPath: newIndexPath!
|
||||
)
|
||||
didMoveObject(observer, monitor, object, indexPath!, newIndexPath!)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -886,12 +865,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
return
|
||||
}
|
||||
didInsertSection(
|
||||
observer: observer,
|
||||
monitor: monitor,
|
||||
sectionInfo: sectionInfo,
|
||||
toIndex: sectionIndex
|
||||
)
|
||||
didInsertSection(observer, monitor, sectionInfo, sectionIndex)
|
||||
}
|
||||
)
|
||||
self.registerSectionNotification(
|
||||
@@ -904,12 +878,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
return
|
||||
}
|
||||
didDeleteSection(
|
||||
observer: observer,
|
||||
monitor: monitor,
|
||||
sectionInfo: sectionInfo,
|
||||
fromIndex: sectionIndex
|
||||
)
|
||||
didDeleteSection(observer, monitor, sectionInfo, sectionIndex)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -953,7 +922,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
}
|
||||
self.applyFetchClauses = applyFetchClauses
|
||||
|
||||
self.taskGroup.notify(.main) { [weak self] () -> Void in
|
||||
self.taskGroup.notify(queue: .main) { [weak self] () -> Void in
|
||||
|
||||
guard let `self` = self else {
|
||||
|
||||
@@ -961,7 +930,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
}
|
||||
|
||||
self.fetchedResultsControllerDelegate.enabled = false
|
||||
self.applyFetchClauses(fetchRequest: self.fetchedResultsController.fetchRequest)
|
||||
self.applyFetchClauses(self.fetchedResultsController.fetchRequest)
|
||||
|
||||
self.transactionQueue.async { [weak self] in
|
||||
|
||||
@@ -1000,6 +969,10 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
// MARK: Private
|
||||
|
||||
fileprivate let fetchedResultsController: CoreStoreFetchedResultsController
|
||||
fileprivate let taskGroup = DispatchGroup()
|
||||
fileprivate let sectionIndexTransformer: (_ sectionName: KeyPath?) -> String?
|
||||
|
||||
private var willChangeListKey: Void?
|
||||
private var didChangeListKey: Void?
|
||||
private var willRefetchListKey: Void?
|
||||
@@ -1013,12 +986,9 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
private var didInsertSectionKey: Void?
|
||||
private var didDeleteSectionKey: Void?
|
||||
|
||||
private let fetchedResultsController: CoreStoreFetchedResultsController
|
||||
private let fetchedResultsControllerDelegate: FetchedResultsControllerDelegate<T>
|
||||
private let sectionIndexTransformer: (_ sectionName: KeyPath?) -> String?
|
||||
private var observerForWillChangePersistentStore: NotificationObserver!
|
||||
private var observerForDidChangePersistentStore: NotificationObserver!
|
||||
private let taskGroup = DispatchGroup()
|
||||
private let transactionQueue: DispatchQueue
|
||||
private var applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void
|
||||
|
||||
@@ -1043,7 +1013,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
private init(context: NSManagedObjectContext, transactionQueue: DispatchQueue, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: ((ListMonitor<T>) -> Void)?) {
|
||||
private init(context: NSManagedObjectContext, transactionQueue: DispatchQueue, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: ((ListMonitor<T>) -> Void)?) {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest<T>()
|
||||
fetchRequest.fetchLimit = 0
|
||||
@@ -1139,7 +1109,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
transactionQueue.async {
|
||||
|
||||
try! fetchedResultsController.performFetchFromSpecifiedStores()
|
||||
self.taskGroup.notify(.main) {
|
||||
self.taskGroup.notify(queue: .main) {
|
||||
|
||||
createAsynchronously(self)
|
||||
}
|
||||
@@ -1184,7 +1154,7 @@ extension ListMonitor: FetchedResultsControllerHandler {
|
||||
|
||||
// MARK: FetchedResultsControllerHandler
|
||||
|
||||
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: AnyObject, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
|
||||
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: Any, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
|
||||
|
||||
switch type {
|
||||
|
||||
@@ -1193,8 +1163,8 @@ extension ListMonitor: FetchedResultsControllerHandler {
|
||||
name: Notification.Name.listMonitorDidInsertObject,
|
||||
object: self,
|
||||
userInfo: [
|
||||
String(NSManagedObject.self): anObject,
|
||||
"\(String(IndexPath.self)).New": newIndexPath!
|
||||
String(describing: NSManagedObject.self): anObject,
|
||||
"\(String(describing: IndexPath.self)).New": newIndexPath!
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1203,8 +1173,8 @@ extension ListMonitor: FetchedResultsControllerHandler {
|
||||
name: Notification.Name.listMonitorDidDeleteObject,
|
||||
object: self,
|
||||
userInfo: [
|
||||
String(NSManagedObject.self): anObject,
|
||||
String(IndexPath.self): indexPath!
|
||||
String(describing: NSManagedObject.self): anObject,
|
||||
String(describing: IndexPath.self): indexPath!
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1213,8 +1183,8 @@ extension ListMonitor: FetchedResultsControllerHandler {
|
||||
name: Notification.Name.listMonitorDidUpdateObject,
|
||||
object: self,
|
||||
userInfo: [
|
||||
String(NSManagedObject.self): anObject,
|
||||
String(IndexPath.self): indexPath!
|
||||
String(describing: NSManagedObject.self): anObject,
|
||||
String(describing: IndexPath.self): indexPath!
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1223,9 +1193,9 @@ extension ListMonitor: FetchedResultsControllerHandler {
|
||||
name: Notification.Name.listMonitorDidMoveObject,
|
||||
object: self,
|
||||
userInfo: [
|
||||
String(NSManagedObject.self): anObject,
|
||||
String(IndexPath.self): indexPath!,
|
||||
"\(String(IndexPath.self)).New": newIndexPath!
|
||||
String(describing: NSManagedObject.self): anObject,
|
||||
String(describing: IndexPath.self): indexPath!,
|
||||
"\(String(describing: IndexPath.self)).New": newIndexPath!
|
||||
]
|
||||
)
|
||||
}
|
||||
@@ -1240,8 +1210,8 @@ extension ListMonitor: FetchedResultsControllerHandler {
|
||||
name: Notification.Name.listMonitorDidInsertSection,
|
||||
object: self,
|
||||
userInfo: [
|
||||
String(NSFetchedResultsSectionInfo.self): sectionInfo,
|
||||
String(NSNumber.self): NSNumber(value: sectionIndex)
|
||||
String(describing: NSFetchedResultsSectionInfo.self): sectionInfo,
|
||||
String(describing: NSNumber.self): NSNumber(value: sectionIndex)
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1250,8 +1220,8 @@ extension ListMonitor: FetchedResultsControllerHandler {
|
||||
name: Notification.Name.listMonitorDidDeleteSection,
|
||||
object: self,
|
||||
userInfo: [
|
||||
String(NSFetchedResultsSectionInfo.self): sectionInfo,
|
||||
String(NSNumber.self): NSNumber(value: sectionIndex)
|
||||
String(describing: NSFetchedResultsSectionInfo.self): sectionInfo,
|
||||
String(describing: NSNumber.self): NSNumber(value: sectionIndex)
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1280,25 +1250,25 @@ extension ListMonitor: FetchedResultsControllerHandler {
|
||||
|
||||
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, sectionIndexTitleForSectionName sectionName: String?) -> String? {
|
||||
|
||||
return self.sectionIndexTransformer(sectionName: sectionName)
|
||||
return self.sectionIndexTransformer(sectionName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Notification Keys
|
||||
|
||||
private extension Notification.Name {
|
||||
fileprivate extension Notification.Name {
|
||||
|
||||
private static let listMonitorWillChangeList = Notification.Name(rawValue: "listMonitorWillChangeList")
|
||||
private static let listMonitorDidChangeList = Notification.Name(rawValue: "listMonitorDidChangeList")
|
||||
private static let listMonitorWillRefetchList = Notification.Name(rawValue: "listMonitorWillRefetchList")
|
||||
private static let listMonitorDidRefetchList = Notification.Name(rawValue: "listMonitorDidRefetchList")
|
||||
private static let listMonitorDidInsertObject = Notification.Name(rawValue: "listMonitorDidInsertObject")
|
||||
private static let listMonitorDidDeleteObject = Notification.Name(rawValue: "listMonitorDidDeleteObject")
|
||||
private static let listMonitorDidUpdateObject = Notification.Name(rawValue: "listMonitorDidUpdateObject")
|
||||
private static let listMonitorDidMoveObject = Notification.Name(rawValue: "listMonitorDidMoveObject")
|
||||
private static let listMonitorDidInsertSection = Notification.Name(rawValue: "listMonitorDidInsertSection")
|
||||
private static let listMonitorDidDeleteSection = Notification.Name(rawValue: "listMonitorDidDeleteSection")
|
||||
fileprivate static let listMonitorWillChangeList = Notification.Name(rawValue: "listMonitorWillChangeList")
|
||||
fileprivate static let listMonitorDidChangeList = Notification.Name(rawValue: "listMonitorDidChangeList")
|
||||
fileprivate static let listMonitorWillRefetchList = Notification.Name(rawValue: "listMonitorWillRefetchList")
|
||||
fileprivate static let listMonitorDidRefetchList = Notification.Name(rawValue: "listMonitorDidRefetchList")
|
||||
fileprivate static let listMonitorDidInsertObject = Notification.Name(rawValue: "listMonitorDidInsertObject")
|
||||
fileprivate static let listMonitorDidDeleteObject = Notification.Name(rawValue: "listMonitorDidDeleteObject")
|
||||
fileprivate static let listMonitorDidUpdateObject = Notification.Name(rawValue: "listMonitorDidUpdateObject")
|
||||
fileprivate static let listMonitorDidMoveObject = Notification.Name(rawValue: "listMonitorDidMoveObject")
|
||||
fileprivate static let listMonitorDidInsertSection = Notification.Name(rawValue: "listMonitorDidInsertSection")
|
||||
fileprivate static let listMonitorDidDeleteSection = Notification.Name(rawValue: "listMonitorDidDeleteSection")
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -322,7 +322,7 @@ extension ObjectMonitor: FetchedResultsControllerHandler {
|
||||
|
||||
internal func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) { }
|
||||
|
||||
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: AnyObject, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
|
||||
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: Any, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
|
||||
|
||||
switch type {
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public extension UnsafeDataTransaction {
|
||||
- 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.
|
||||
*/
|
||||
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
|
||||
public func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
|
||||
|
||||
self.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public extension UnsafeDataTransaction {
|
||||
- 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.
|
||||
*/
|
||||
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
|
||||
public func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
|
||||
|
||||
CoreStore.assert(
|
||||
fetchClauses.filter { $0 is OrderBy }.count > 0,
|
||||
@@ -169,7 +169,7 @@ public extension UnsafeDataTransaction {
|
||||
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||
*/
|
||||
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
|
||||
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
|
||||
|
||||
self.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public extension UnsafeDataTransaction {
|
||||
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||
*/
|
||||
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
|
||||
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
|
||||
|
||||
CoreStore.assert(
|
||||
fetchClauses.filter { $0 is OrderBy }.count > 0,
|
||||
|
||||
@@ -241,7 +241,7 @@ public final class DataStack {
|
||||
do {
|
||||
|
||||
try FileManager.default.createDirectory(
|
||||
at: try fileURL.deletingLastPathComponent(),
|
||||
at: fileURL.deletingLastPathComponent(),
|
||||
withIntermediateDirectories: true,
|
||||
attributes: nil
|
||||
)
|
||||
@@ -336,7 +336,7 @@ public final class DataStack {
|
||||
do {
|
||||
|
||||
try FileManager.default.createDirectory(
|
||||
at: try cacheFileURL.deletingLastPathComponent(),
|
||||
at: cacheFileURL.deletingLastPathComponent(),
|
||||
withIntermediateDirectories: true,
|
||||
attributes: nil
|
||||
)
|
||||
@@ -394,11 +394,8 @@ public final class DataStack {
|
||||
migrationQueue.name = "com.coreStore.migrationOperationQueue"
|
||||
migrationQueue.qualityOfService = .utility
|
||||
migrationQueue.underlyingQueue = DispatchQueue(
|
||||
label: "com.coreStore.migrationQueue",
|
||||
qos: .userInitiated,
|
||||
attributes: .allZeros,
|
||||
autoreleaseFrequency: .workItem,
|
||||
target: nil
|
||||
serialWith: "com.coreStore.migrationQueue",
|
||||
qos: .userInitiated
|
||||
)
|
||||
return migrationQueue
|
||||
}()
|
||||
@@ -462,7 +459,7 @@ public final class DataStack {
|
||||
return returnValue
|
||||
}
|
||||
|
||||
internal func createPersistentStoreFromStorage(_ storage: StorageInterface, finalURL: URL?, finalStoreOptions: [String: AnyObject]?) throws -> NSPersistentStore {
|
||||
internal func createPersistentStoreFromStorage(_ storage: StorageInterface, finalURL: URL?, finalStoreOptions: [AnyHashable: Any]?) throws -> NSPersistentStore {
|
||||
|
||||
let persistentStore = try self.coordinator.addPersistentStore(
|
||||
ofType: type(of: storage).storeType,
|
||||
|
||||
@@ -85,12 +85,12 @@ public class ICloudStore: CloudStorage {
|
||||
)
|
||||
|
||||
let fileManager = FileManager.default
|
||||
guard let cacheFileURL = fileManager.urlForUbiquityContainerIdentifier(ubiquitousContainerID) else {
|
||||
guard let cacheFileURL = fileManager.url(forUbiquityContainerIdentifier: ubiquitousContainerID) else {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var storeOptions: [String: AnyObject] = [
|
||||
var storeOptions: [String: Any] = [
|
||||
NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSPersistentStoreUbiquitousContentNameKey: ubiquitousContentName
|
||||
]
|
||||
@@ -265,7 +265,7 @@ public class ICloudStore: CloudStorage {
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
```
|
||||
*/
|
||||
public let storeOptions: [String: AnyObject]?
|
||||
public let storeOptions: [AnyHashable: Any]?
|
||||
|
||||
/**
|
||||
Do not call directly. Used by the `DataStack` internally.
|
||||
@@ -312,7 +312,7 @@ public class ICloudStore: CloudStorage {
|
||||
NotificationCenter.default.post(
|
||||
name: notification,
|
||||
object: self,
|
||||
userInfo: [String(DataStack.self): dataStack]
|
||||
userInfo: [String(describing: DataStack.self): dataStack]
|
||||
)
|
||||
}
|
||||
),
|
||||
@@ -354,7 +354,7 @@ public class ICloudStore: CloudStorage {
|
||||
NotificationCenter.default.post(
|
||||
name: notification,
|
||||
object: self,
|
||||
userInfo: [String(DataStack.self): dataStack]
|
||||
userInfo: [String(describing: DataStack.self): dataStack]
|
||||
)
|
||||
}
|
||||
),
|
||||
@@ -400,7 +400,7 @@ public class ICloudStore: CloudStorage {
|
||||
/**
|
||||
The options dictionary for the specified `CloudStorageOptions`
|
||||
*/
|
||||
public func storeOptionsForOptions(_ options: CloudStorageOptions) -> [String: AnyObject]? {
|
||||
public func storeOptionsForOptions(_ options: CloudStorageOptions) -> [AnyHashable: Any]? {
|
||||
|
||||
if options == .none {
|
||||
|
||||
@@ -453,10 +453,10 @@ public class ICloudStore: CloudStorage {
|
||||
|
||||
// MARK: Private
|
||||
|
||||
private struct Static {
|
||||
fileprivate struct Static {
|
||||
|
||||
private static var persistentStoreCoordinatorWillChangeStores: Void?
|
||||
private static var persistentStoreCoordinatorDidChangeStores: Void?
|
||||
fileprivate static var persistentStoreCoordinatorWillChangeStores: Void?
|
||||
fileprivate static var persistentStoreCoordinatorDidChangeStores: Void?
|
||||
}
|
||||
|
||||
private var willFinishInitialImportKey: Void?
|
||||
@@ -480,7 +480,7 @@ public class ICloudStore: CloudStorage {
|
||||
|
||||
guard let `self` = self,
|
||||
let observer = observer,
|
||||
let dataStack = note.userInfo?[String(DataStack.self)] as? DataStack,
|
||||
let dataStack = note.userInfo?[String(describing: DataStack.self)] as? DataStack,
|
||||
self.dataStack === dataStack else {
|
||||
|
||||
return
|
||||
@@ -497,16 +497,16 @@ public class ICloudStore: CloudStorage {
|
||||
|
||||
// MARK: - Notification Keys
|
||||
|
||||
private extension Notification.Name {
|
||||
fileprivate extension Notification.Name {
|
||||
|
||||
private static let iCloudUbiquitousStoreWillFinishInitialImport = Notification.Name(rawValue: "iCloudUbiquitousStoreWillFinishInitialImport")
|
||||
private static let iCloudUbiquitousStoreDidFinishInitialImport = Notification.Name(rawValue: "iCloudUbiquitousStoreDidFinishInitialImport")
|
||||
private static let iCloudUbiquitousStoreWillAddAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreWillAddAccount")
|
||||
private static let iCloudUbiquitousStoreDidAddAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreDidAddAccount")
|
||||
private static let iCloudUbiquitousStoreWillRemoveAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreWillRemoveAccount")
|
||||
private static let iCloudUbiquitousStoreDidRemoveAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreDidRemoveAccount")
|
||||
private static let iCloudUbiquitousStoreWillRemoveContent = Notification.Name(rawValue: "iCloudUbiquitousStoreWillRemoveContent")
|
||||
private static let iCloudUbiquitousStoreDidRemoveContent = Notification.Name(rawValue: "iCloudUbiquitousStoreDidRemoveContent")
|
||||
fileprivate static let iCloudUbiquitousStoreWillFinishInitialImport = Notification.Name(rawValue: "iCloudUbiquitousStoreWillFinishInitialImport")
|
||||
fileprivate static let iCloudUbiquitousStoreDidFinishInitialImport = Notification.Name(rawValue: "iCloudUbiquitousStoreDidFinishInitialImport")
|
||||
fileprivate static let iCloudUbiquitousStoreWillAddAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreWillAddAccount")
|
||||
fileprivate static let iCloudUbiquitousStoreDidAddAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreDidAddAccount")
|
||||
fileprivate static let iCloudUbiquitousStoreWillRemoveAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreWillRemoveAccount")
|
||||
fileprivate static let iCloudUbiquitousStoreDidRemoveAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreDidRemoveAccount")
|
||||
fileprivate static let iCloudUbiquitousStoreWillRemoveContent = Notification.Name(rawValue: "iCloudUbiquitousStoreWillRemoveContent")
|
||||
fileprivate static let iCloudUbiquitousStoreDidRemoveContent = Notification.Name(rawValue: "iCloudUbiquitousStoreDidRemoveContent")
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -69,7 +69,7 @@ public final class InMemoryStore: StorageInterface, DefaultInitializableStore {
|
||||
/**
|
||||
The options dictionary for the `NSPersistentStore`. For `InMemoryStore`s, this is always set to `nil`.
|
||||
*/
|
||||
public let storeOptions: [String: AnyObject]? = nil
|
||||
public let storeOptions: [AnyHashable: Any]? = nil
|
||||
|
||||
/**
|
||||
Do not call directly. Used by the `DataStack` internally.
|
||||
|
||||
@@ -63,7 +63,7 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
*/
|
||||
public init(fileName: String, configuration: String? = nil, mappingModelBundles: [Bundle] = Bundle.allBundles, localStorageOptions: LocalStorageOptions = nil) {
|
||||
|
||||
self.fileURL = try! LegacySQLiteStore.defaultRootDirectory.appendingPathComponent(
|
||||
self.fileURL = LegacySQLiteStore.defaultRootDirectory.appendingPathComponent(
|
||||
fileName,
|
||||
isDirectory: false
|
||||
)
|
||||
@@ -99,7 +99,7 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
/**
|
||||
The options dictionary for the specified `LocalStorageOptions`
|
||||
*/
|
||||
public func storeOptionsForOptions(_ options: LocalStorageOptions) -> [String: AnyObject]? {
|
||||
public func storeOptionsForOptions(_ options: LocalStorageOptions) -> [AnyHashable: Any]? {
|
||||
|
||||
if options == .none {
|
||||
|
||||
@@ -126,7 +126,7 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
```
|
||||
*/
|
||||
public let storeOptions: [String: AnyObject]? = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
public let storeOptions: [AnyHashable: Any]? = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
|
||||
/**
|
||||
Do not call directly. Used by the `DataStack` internally.
|
||||
@@ -184,12 +184,12 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
let fileManager = FileManager.default
|
||||
do {
|
||||
|
||||
let temporaryFile = try URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!)
|
||||
let temporaryFile = URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!)
|
||||
.appendingPathComponent(Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack", isDirectory: true)
|
||||
.appendingPathComponent("trash", isDirectory: true)
|
||||
.appendingPathComponent(UUID().uuidString, isDirectory: false)
|
||||
try fileManager.createDirectory(
|
||||
at: try temporaryFile.deletingLastPathComponent(),
|
||||
at: temporaryFile.deletingLastPathComponent(),
|
||||
withIntermediateDirectories: true,
|
||||
attributes: nil
|
||||
)
|
||||
@@ -217,13 +217,12 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
let systemDirectorySearchPath = FileManager.SearchPathDirectory.applicationSupportDirectory
|
||||
#endif
|
||||
|
||||
return FileManager.default.urlsForDirectory(
|
||||
systemDirectorySearchPath,
|
||||
inDomains: .userDomainMask
|
||||
).first!
|
||||
return FileManager.default.urls(
|
||||
for: systemDirectorySearchPath,
|
||||
in: .userDomainMask).first!
|
||||
}()
|
||||
|
||||
internal static let defaultFileURL = try! LegacySQLiteStore.defaultRootDirectory
|
||||
internal static let defaultFileURL = LegacySQLiteStore.defaultRootDirectory
|
||||
.appendingPathComponent(DataStack.applicationName, isDirectory: false)
|
||||
.appendingPathExtension("sqlite")
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
*/
|
||||
public init(fileName: String, configuration: String? = nil, mappingModelBundles: [Bundle] = Bundle.allBundles, localStorageOptions: LocalStorageOptions = nil) {
|
||||
|
||||
self.fileURL = try! SQLiteStore.defaultRootDirectory
|
||||
self.fileURL = SQLiteStore.defaultRootDirectory
|
||||
.appendingPathComponent(fileName, isDirectory: false)
|
||||
self.configuration = configuration
|
||||
self.mappingModelBundles = mappingModelBundles
|
||||
@@ -104,7 +104,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
```
|
||||
*/
|
||||
public let storeOptions: [String: AnyObject]? = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
public let storeOptions: [AnyHashable: Any]? = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
|
||||
/**
|
||||
Do not call directly. Used by the `DataStack` internally.
|
||||
@@ -143,7 +143,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
/**
|
||||
The options dictionary for the specified `LocalStorageOptions`
|
||||
*/
|
||||
public func storeOptionsForOptions(_ options: LocalStorageOptions) -> [String: AnyObject]? {
|
||||
public func storeOptionsForOptions(_ options: LocalStorageOptions) -> [AnyHashable: Any]? {
|
||||
|
||||
if options == .none {
|
||||
|
||||
@@ -181,12 +181,12 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
let fileManager = FileManager.default
|
||||
do {
|
||||
|
||||
let temporaryFile = try URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!)
|
||||
let temporaryFile = URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!)
|
||||
.appendingPathComponent(Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack", isDirectory: true)
|
||||
.appendingPathComponent("trash", isDirectory: true)
|
||||
.appendingPathComponent(UUID().uuidString, isDirectory: false)
|
||||
try fileManager.createDirectory(
|
||||
at: try temporaryFile.deletingLastPathComponent(),
|
||||
at: temporaryFile.deletingLastPathComponent(),
|
||||
withIntermediateDirectories: true,
|
||||
attributes: nil
|
||||
)
|
||||
@@ -214,10 +214,11 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
let systemDirectorySearchPath = FileManager.SearchPathDirectory.applicationSupportDirectory
|
||||
#endif
|
||||
|
||||
let defaultSystemDirectory = FileManager.default
|
||||
.urlsForDirectory(systemDirectorySearchPath, inDomains: .userDomainMask).first!
|
||||
let defaultSystemDirectory = FileManager.default.urls(
|
||||
for: systemDirectorySearchPath,
|
||||
in: .userDomainMask).first!
|
||||
|
||||
return try! defaultSystemDirectory.appendingPathComponent(
|
||||
return defaultSystemDirectory.appendingPathComponent(
|
||||
Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack",
|
||||
isDirectory: true
|
||||
)
|
||||
|
||||
@@ -46,7 +46,7 @@ public protocol StorageInterface: class {
|
||||
/**
|
||||
The options dictionary for the `NSPersistentStore`
|
||||
*/
|
||||
var storeOptions: [String: AnyObject]? { get }
|
||||
var storeOptions: [AnyHashable: Any]? { get }
|
||||
|
||||
|
||||
// MARK: Internal (Do not call these directly)
|
||||
@@ -153,7 +153,7 @@ public protocol LocalStorage: StorageInterface {
|
||||
/**
|
||||
The options dictionary for the specified `LocalStorageOptions`
|
||||
*/
|
||||
func storeOptionsForOptions(_ options: LocalStorageOptions) -> [String: AnyObject]?
|
||||
func storeOptionsForOptions(_ options: LocalStorageOptions) -> [AnyHashable: Any]?
|
||||
|
||||
/**
|
||||
Called by the `DataStack` to perform actual deletion of the store file from disk. **Do not call directly!** The `sourceModel` argument is a hint for the existing store's model version. Implementers can use the `sourceModel` to perform necessary store operations. (SQLite stores for example, can convert WAL journaling mode to DELETE before deleting)
|
||||
@@ -237,7 +237,7 @@ public protocol CloudStorage: StorageInterface {
|
||||
/**
|
||||
The options dictionary for the specified `CloudStorageOptions`
|
||||
*/
|
||||
func storeOptionsForOptions(_ options: CloudStorageOptions) -> [String: AnyObject]?
|
||||
func storeOptionsForOptions(_ options: CloudStorageOptions) -> [AnyHashable: Any]?
|
||||
|
||||
/**
|
||||
Called by the `DataStack` to perform actual deletion of the store file from disk. **Do not call directly!** The `sourceModel` argument is a hint for the existing store's model version. Implementers can use the `sourceModel` to perform necessary store operations. (Cloud stores for example, can set the NSPersistentStoreRemoveUbiquitousMetadataOption option before deleting)
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
|
||||
public func commit(_ completion: @escaping (_ result: SaveResult) -> Void = { _ in }) {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to commit a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -69,10 +69,10 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
|
||||
- returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
|
||||
*/
|
||||
@discardableResult
|
||||
public func beginSynchronous(_ closure: (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
|
||||
public func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to begin a child transaction from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -188,7 +188,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
internal init(mainContext: NSManagedObjectContext, queue: DispatchQueue, closure: (_ transaction: AsynchronousDataTransaction) -> Void) {
|
||||
internal init(mainContext: NSManagedObjectContext, queue: DispatchQueue, closure: @escaping (_ transaction: AsynchronousDataTransaction) -> Void) {
|
||||
|
||||
self.closure = closure
|
||||
|
||||
@@ -199,7 +199,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
|
||||
|
||||
self.transactionQueue.async {
|
||||
|
||||
self.closure(transaction: self)
|
||||
self.closure(self)
|
||||
if !self.isCommitted && self.hasChanges {
|
||||
|
||||
CoreStore.log(
|
||||
@@ -214,7 +214,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
|
||||
|
||||
self.transactionQueue.sync {
|
||||
|
||||
self.closure(transaction: self)
|
||||
self.closure(self)
|
||||
|
||||
if !self.isCommitted && self.hasChanges {
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func insertedObjects() -> Set<NSManagedObject> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access inserted objects from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -239,7 +239,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func insertedObjects<T: NSManagedObject>(_ entity: T.Type) -> Set<T> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access inserted objects from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -258,7 +258,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func insertedObjectIDs() -> Set<NSManagedObjectID> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access inserted object IDs from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -278,7 +278,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func insertedObjectIDs<T: NSManagedObject>(_ entity: T.Type) -> Set<NSManagedObjectID> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access inserted object IDs from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -297,7 +297,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func updatedObjects() -> Set<NSManagedObject> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access updated objects from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -317,7 +317,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func updatedObjects<T: NSManagedObject>(_ entity: T.Type) -> Set<T> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access updated objects from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -336,7 +336,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func updatedObjectIDs() -> Set<NSManagedObjectID> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access updated object IDs from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -356,7 +356,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func updatedObjectIDs<T: NSManagedObject>(_ entity: T.Type) -> Set<NSManagedObjectID> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access updated object IDs from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -375,7 +375,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func deletedObjects() -> Set<NSManagedObject> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access deleted objects from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -395,7 +395,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func deletedObjects<T: NSManagedObject>(_ entity: T.Type) -> Set<T> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access deleted objects from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -415,7 +415,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func deletedObjectIDs() -> Set<NSManagedObjectID> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access deleted object IDs from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -435,7 +435,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
public func deletedObjectIDs<T: NSManagedObject>(_ entity: T.Type) -> Set<NSManagedObjectID> {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to access deleted object IDs from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -484,6 +484,6 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
|
||||
internal func isRunningInAllowedQueue() -> Bool {
|
||||
|
||||
return self.bypassesQueueing || self.transactionQueue.isCurrentExecutionContext()
|
||||
return self.bypassesQueueing || self.transactionQueue.cs_isCurrentExecutionContext()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public extension CoreStore {
|
||||
|
||||
- parameter closure: the block 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`.
|
||||
*/
|
||||
public static func beginAsynchronous(_ closure: (_ transaction: AsynchronousDataTransaction) -> Void) {
|
||||
public static func beginAsynchronous(_ closure: @escaping (_ transaction: AsynchronousDataTransaction) -> Void) {
|
||||
|
||||
self.defaultStack.beginAsynchronous(closure)
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public extension CoreStore {
|
||||
- returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
|
||||
*/
|
||||
@discardableResult
|
||||
public static func beginSynchronous(_ closure: (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
|
||||
public static func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
|
||||
|
||||
return self.defaultStack.beginSynchronous(closure)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public extension DataStack {
|
||||
|
||||
- parameter closure: the block 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`.
|
||||
*/
|
||||
public func beginAsynchronous(_ closure: (_ transaction: AsynchronousDataTransaction) -> Void) {
|
||||
public func beginAsynchronous(_ closure: @escaping (_ transaction: AsynchronousDataTransaction) -> Void) {
|
||||
|
||||
AsynchronousDataTransaction(
|
||||
mainContext: self.rootSavingContext,
|
||||
@@ -51,7 +51,7 @@ public extension DataStack {
|
||||
- returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
|
||||
*/
|
||||
@discardableResult
|
||||
public func beginSynchronous(_ closure: (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
|
||||
public func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
|
||||
|
||||
return SynchronousDataTransaction(
|
||||
mainContext: self.rootSavingContext,
|
||||
@@ -69,9 +69,9 @@ public extension DataStack {
|
||||
|
||||
return UnsafeDataTransaction(
|
||||
mainContext: self.rootSavingContext,
|
||||
queue: .createSerial(
|
||||
"com.coreStore.dataStack.unsafeTransactionQueue",
|
||||
targetQueue: .userInitiated
|
||||
queue: DispatchQueue(
|
||||
serialWith: "com.coreStore.dataStack.unsafeTransactionQueue",
|
||||
qos: .userInitiated
|
||||
),
|
||||
supportsUndo: supportsUndo
|
||||
)
|
||||
|
||||
@@ -50,7 +50,7 @@ public extension NSManagedObject {
|
||||
@nonobjc
|
||||
internal class func createInContext(_ context: NSManagedObjectContext) -> Self {
|
||||
|
||||
return self.`init`(entity:insertInto:)(
|
||||
return self.init(
|
||||
entity: context.entityDescriptionForEntityType(self)!,
|
||||
insertInto: context
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
public func commitAndWait() -> SaveResult {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to commit a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -64,10 +64,10 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
- returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
|
||||
*/
|
||||
@discardableResult
|
||||
public func beginSynchronous(_ closure: (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
|
||||
public func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to begin a child transaction from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -183,7 +183,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
internal init(mainContext: NSManagedObjectContext, queue: DispatchQueue, closure: (_ transaction: SynchronousDataTransaction) -> Void) {
|
||||
internal init(mainContext: NSManagedObjectContext, queue: DispatchQueue, closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) {
|
||||
|
||||
self.closure = closure
|
||||
|
||||
@@ -194,7 +194,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
|
||||
self.transactionQueue.sync {
|
||||
|
||||
self.closure(transaction: self)
|
||||
self.closure(self)
|
||||
|
||||
if !self.isCommitted && self.hasChanges {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user