mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-29 13:51:48 +02:00
NSManagedObject features are now fully supported for CoreStoreObject types. MacOSX 10.12 onwards now support ListMonitors and ObjectMonitors
This commit is contained in:
@@ -84,6 +84,10 @@
|
|||||||
B509C7F51E54511B0061C547 /* ImportableAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* ImportableAttributeType.swift */; };
|
B509C7F51E54511B0061C547 /* ImportableAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* ImportableAttributeType.swift */; };
|
||||||
B509C7F61E54511B0061C547 /* ImportableAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* ImportableAttributeType.swift */; };
|
B509C7F61E54511B0061C547 /* ImportableAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* ImportableAttributeType.swift */; };
|
||||||
B509C7F71E54511B0061C547 /* ImportableAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* ImportableAttributeType.swift */; };
|
B509C7F71E54511B0061C547 /* ImportableAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* ImportableAttributeType.swift */; };
|
||||||
|
B512607F1E97A18000402229 /* CoreStoreObject+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B512607E1E97A18000402229 /* CoreStoreObject+Convenience.swift */; };
|
||||||
|
B51260801E97A18000402229 /* CoreStoreObject+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B512607E1E97A18000402229 /* CoreStoreObject+Convenience.swift */; };
|
||||||
|
B51260811E97A18000402229 /* CoreStoreObject+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B512607E1E97A18000402229 /* CoreStoreObject+Convenience.swift */; };
|
||||||
|
B51260821E97A18000402229 /* CoreStoreObject+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B512607E1E97A18000402229 /* CoreStoreObject+Convenience.swift */; };
|
||||||
B51BE06A1B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51BE0691B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift */; };
|
B51BE06A1B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51BE0691B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift */; };
|
||||||
B51FE5AB1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51FE5AA1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift */; };
|
B51FE5AB1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51FE5AA1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift */; };
|
||||||
B51FE5AD1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51FE5AA1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift */; };
|
B51FE5AD1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51FE5AA1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift */; };
|
||||||
@@ -413,25 +417,25 @@
|
|||||||
B5C976E81C6E3A5D00B1AF90 /* CoreStoreFetchedResultsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C976E61C6E3A5900B1AF90 /* CoreStoreFetchedResultsController.swift */; };
|
B5C976E81C6E3A5D00B1AF90 /* CoreStoreFetchedResultsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C976E61C6E3A5900B1AF90 /* CoreStoreFetchedResultsController.swift */; };
|
||||||
B5C976E91C6E3A5E00B1AF90 /* CoreStoreFetchedResultsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C976E61C6E3A5900B1AF90 /* CoreStoreFetchedResultsController.swift */; };
|
B5C976E91C6E3A5E00B1AF90 /* CoreStoreFetchedResultsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C976E61C6E3A5900B1AF90 /* CoreStoreFetchedResultsController.swift */; };
|
||||||
B5D1E22C19FA9FBC003B2874 /* CoreStoreError.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D1E22B19FA9FBC003B2874 /* CoreStoreError.swift */; };
|
B5D1E22C19FA9FBC003B2874 /* CoreStoreError.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D1E22B19FA9FBC003B2874 /* CoreStoreError.swift */; };
|
||||||
B5D339AF1E925BF200C880DE /* ObjectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339AE1E925BF200C880DE /* ObjectModel.swift */; };
|
B5D339AF1E925BF200C880DE /* DynamicModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339AE1E925BF200C880DE /* DynamicModel.swift */; };
|
||||||
B5D339B01E925BF200C880DE /* ObjectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339AE1E925BF200C880DE /* ObjectModel.swift */; };
|
B5D339B01E925BF200C880DE /* DynamicModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339AE1E925BF200C880DE /* DynamicModel.swift */; };
|
||||||
B5D339B11E925BF200C880DE /* ObjectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339AE1E925BF200C880DE /* ObjectModel.swift */; };
|
B5D339B11E925BF200C880DE /* DynamicModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339AE1E925BF200C880DE /* DynamicModel.swift */; };
|
||||||
B5D339B21E925BF200C880DE /* ObjectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339AE1E925BF200C880DE /* ObjectModel.swift */; };
|
B5D339B21E925BF200C880DE /* DynamicModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339AE1E925BF200C880DE /* DynamicModel.swift */; };
|
||||||
B5D339B41E925C2B00C880DE /* DynamicModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339B31E925C2B00C880DE /* DynamicModelTests.swift */; };
|
B5D339B41E925C2B00C880DE /* DynamicModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339B31E925C2B00C880DE /* DynamicModelTests.swift */; };
|
||||||
B5D339B51E925C2B00C880DE /* DynamicModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339B31E925C2B00C880DE /* DynamicModelTests.swift */; };
|
B5D339B51E925C2B00C880DE /* DynamicModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339B31E925C2B00C880DE /* DynamicModelTests.swift */; };
|
||||||
B5D339B61E925C2B00C880DE /* DynamicModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339B31E925C2B00C880DE /* DynamicModelTests.swift */; };
|
B5D339B61E925C2B00C880DE /* DynamicModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339B31E925C2B00C880DE /* DynamicModelTests.swift */; };
|
||||||
B5D339D81E9489AB00C880DE /* ManagedObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339D71E9489AB00C880DE /* ManagedObject.swift */; };
|
B5D339D81E9489AB00C880DE /* CoreStoreObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339D71E9489AB00C880DE /* CoreStoreObject.swift */; };
|
||||||
B5D339D91E9489AB00C880DE /* ManagedObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339D71E9489AB00C880DE /* ManagedObject.swift */; };
|
B5D339D91E9489AB00C880DE /* CoreStoreObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339D71E9489AB00C880DE /* CoreStoreObject.swift */; };
|
||||||
B5D339DA1E9489AB00C880DE /* ManagedObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339D71E9489AB00C880DE /* ManagedObject.swift */; };
|
B5D339DA1E9489AB00C880DE /* CoreStoreObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339D71E9489AB00C880DE /* CoreStoreObject.swift */; };
|
||||||
B5D339DB1E9489AB00C880DE /* ManagedObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339D71E9489AB00C880DE /* ManagedObject.swift */; };
|
B5D339DB1E9489AB00C880DE /* CoreStoreObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339D71E9489AB00C880DE /* CoreStoreObject.swift */; };
|
||||||
B5D339DD1E9489C700C880DE /* ManagedObjectProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339DC1E9489C700C880DE /* ManagedObjectProtocol.swift */; };
|
B5D339DD1E9489C700C880DE /* DynamicObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339DC1E9489C700C880DE /* DynamicObject.swift */; };
|
||||||
B5D339DE1E9489C700C880DE /* ManagedObjectProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339DC1E9489C700C880DE /* ManagedObjectProtocol.swift */; };
|
B5D339DE1E9489C700C880DE /* DynamicObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339DC1E9489C700C880DE /* DynamicObject.swift */; };
|
||||||
B5D339DF1E9489C700C880DE /* ManagedObjectProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339DC1E9489C700C880DE /* ManagedObjectProtocol.swift */; };
|
B5D339DF1E9489C700C880DE /* DynamicObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339DC1E9489C700C880DE /* DynamicObject.swift */; };
|
||||||
B5D339E01E9489C700C880DE /* ManagedObjectProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339DC1E9489C700C880DE /* ManagedObjectProtocol.swift */; };
|
B5D339E01E9489C700C880DE /* DynamicObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339DC1E9489C700C880DE /* DynamicObject.swift */; };
|
||||||
B5D339E21E948C3600C880DE /* Attribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E11E948C3600C880DE /* Attribute.swift */; };
|
B5D339E21E948C3600C880DE /* Value.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E11E948C3600C880DE /* Value.swift */; };
|
||||||
B5D339E31E948C3600C880DE /* Attribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E11E948C3600C880DE /* Attribute.swift */; };
|
B5D339E31E948C3600C880DE /* Value.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E11E948C3600C880DE /* Value.swift */; };
|
||||||
B5D339E41E948C3600C880DE /* Attribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E11E948C3600C880DE /* Attribute.swift */; };
|
B5D339E41E948C3600C880DE /* Value.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E11E948C3600C880DE /* Value.swift */; };
|
||||||
B5D339E51E948C3600C880DE /* Attribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E11E948C3600C880DE /* Attribute.swift */; };
|
B5D339E51E948C3600C880DE /* Value.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E11E948C3600C880DE /* Value.swift */; };
|
||||||
B5D339E71E9493A500C880DE /* Entity.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E61E9493A500C880DE /* Entity.swift */; };
|
B5D339E71E9493A500C880DE /* Entity.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E61E9493A500C880DE /* Entity.swift */; };
|
||||||
B5D339E81E9493A500C880DE /* Entity.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E61E9493A500C880DE /* Entity.swift */; };
|
B5D339E81E9493A500C880DE /* Entity.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E61E9493A500C880DE /* Entity.swift */; };
|
||||||
B5D339E91E9493A500C880DE /* Entity.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E61E9493A500C880DE /* Entity.swift */; };
|
B5D339E91E9493A500C880DE /* Entity.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D339E61E9493A500C880DE /* Entity.swift */; };
|
||||||
@@ -648,6 +652,7 @@
|
|||||||
B50392F81C478FF3009900CA /* NSManagedObject+Transaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObject+Transaction.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>"; };
|
B504D0D51B02362500B2BBB1 /* CoreStore+Setup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CoreStore+Setup.swift"; sourceTree = "<group>"; };
|
||||||
B509C7F31E54511B0061C547 /* ImportableAttributeType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImportableAttributeType.swift; sourceTree = "<group>"; };
|
B509C7F31E54511B0061C547 /* ImportableAttributeType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImportableAttributeType.swift; sourceTree = "<group>"; };
|
||||||
|
B512607E1E97A18000402229 /* CoreStoreObject+Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CoreStoreObject+Convenience.swift"; sourceTree = "<group>"; };
|
||||||
B51BE0691B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObjectModel+Setup.swift"; 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>"; };
|
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>"; };
|
B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSFetchedResultsController+Convenience.swift"; sourceTree = "<group>"; };
|
||||||
@@ -728,11 +733,11 @@
|
|||||||
B5C976E21C6C9F6A00B1AF90 /* UnsafeDataTransaction+Observing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UnsafeDataTransaction+Observing.swift"; sourceTree = "<group>"; };
|
B5C976E21C6C9F6A00B1AF90 /* UnsafeDataTransaction+Observing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UnsafeDataTransaction+Observing.swift"; sourceTree = "<group>"; };
|
||||||
B5C976E61C6E3A5900B1AF90 /* CoreStoreFetchedResultsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreFetchedResultsController.swift; sourceTree = "<group>"; };
|
B5C976E61C6E3A5900B1AF90 /* CoreStoreFetchedResultsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreFetchedResultsController.swift; sourceTree = "<group>"; };
|
||||||
B5D1E22B19FA9FBC003B2874 /* CoreStoreError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreError.swift; sourceTree = "<group>"; };
|
B5D1E22B19FA9FBC003B2874 /* CoreStoreError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreError.swift; sourceTree = "<group>"; };
|
||||||
B5D339AE1E925BF200C880DE /* ObjectModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ObjectModel.swift; sourceTree = "<group>"; };
|
B5D339AE1E925BF200C880DE /* DynamicModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicModel.swift; sourceTree = "<group>"; };
|
||||||
B5D339B31E925C2B00C880DE /* DynamicModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicModelTests.swift; sourceTree = "<group>"; };
|
B5D339B31E925C2B00C880DE /* DynamicModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicModelTests.swift; sourceTree = "<group>"; };
|
||||||
B5D339D71E9489AB00C880DE /* ManagedObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManagedObject.swift; sourceTree = "<group>"; };
|
B5D339D71E9489AB00C880DE /* CoreStoreObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreObject.swift; sourceTree = "<group>"; };
|
||||||
B5D339DC1E9489C700C880DE /* ManagedObjectProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManagedObjectProtocol.swift; sourceTree = "<group>"; };
|
B5D339DC1E9489C700C880DE /* DynamicObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicObject.swift; sourceTree = "<group>"; };
|
||||||
B5D339E11E948C3600C880DE /* Attribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Attribute.swift; sourceTree = "<group>"; };
|
B5D339E11E948C3600C880DE /* Value.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Value.swift; sourceTree = "<group>"; };
|
||||||
B5D339E61E9493A500C880DE /* Entity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Entity.swift; sourceTree = "<group>"; };
|
B5D339E61E9493A500C880DE /* Entity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Entity.swift; sourceTree = "<group>"; };
|
||||||
B5D339EB1E9495E500C880DE /* Attribute+Querying.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Attribute+Querying.swift"; sourceTree = "<group>"; };
|
B5D339EB1E9495E500C880DE /* Attribute+Querying.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Attribute+Querying.swift"; sourceTree = "<group>"; };
|
||||||
B5D339F01E94AF5800C880DE /* CoreStoreStrings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreStrings.swift; sourceTree = "<group>"; };
|
B5D339F01E94AF5800C880DE /* CoreStoreStrings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreStrings.swift; sourceTree = "<group>"; };
|
||||||
@@ -1086,12 +1091,12 @@
|
|||||||
B57358D71E5A7F9B0094B50A /* Dynamic Models */ = {
|
B57358D71E5A7F9B0094B50A /* Dynamic Models */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
B5D339E11E948C3600C880DE /* Attribute.swift */,
|
B5D339D71E9489AB00C880DE /* CoreStoreObject.swift */,
|
||||||
B5D33A001E96012400C880DE /* Relationship.swift */,
|
B5D339AE1E925BF200C880DE /* DynamicModel.swift */,
|
||||||
B5D339D71E9489AB00C880DE /* ManagedObject.swift */,
|
B5D339DC1E9489C700C880DE /* DynamicObject.swift */,
|
||||||
B5D339E61E9493A500C880DE /* Entity.swift */,
|
B5D339E61E9493A500C880DE /* Entity.swift */,
|
||||||
B5D339DC1E9489C700C880DE /* ManagedObjectProtocol.swift */,
|
B5D33A001E96012400C880DE /* Relationship.swift */,
|
||||||
B5D339AE1E925BF200C880DE /* ObjectModel.swift */,
|
B5D339E11E948C3600C880DE /* Value.swift */,
|
||||||
);
|
);
|
||||||
path = "Dynamic Models";
|
path = "Dynamic Models";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -1272,6 +1277,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
B5E84F271AFF84920064E85B /* NSManagedObject+Convenience.swift */,
|
B5E84F271AFF84920064E85B /* NSManagedObject+Convenience.swift */,
|
||||||
|
B512607E1E97A18000402229 /* CoreStoreObject+Convenience.swift */,
|
||||||
B5FAD6A81B50A4B300714891 /* Progress+Convenience.swift */,
|
B5FAD6A81B50A4B300714891 /* Progress+Convenience.swift */,
|
||||||
B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */,
|
B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */,
|
||||||
);
|
);
|
||||||
@@ -1631,7 +1637,7 @@
|
|||||||
B529C2041CA4A2DB007E7EBD /* CSSaveResult.swift in Sources */,
|
B529C2041CA4A2DB007E7EBD /* CSSaveResult.swift in Sources */,
|
||||||
B5D1E22C19FA9FBC003B2874 /* CoreStoreError.swift in Sources */,
|
B5D1E22C19FA9FBC003B2874 /* CoreStoreError.swift in Sources */,
|
||||||
B5E84F131AFF847B0064E85B /* Where.swift in Sources */,
|
B5E84F131AFF847B0064E85B /* Where.swift in Sources */,
|
||||||
B5D339D81E9489AB00C880DE /* ManagedObject.swift in Sources */,
|
B5D339D81E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
||||||
B5D3F6451C887C0A00C7492A /* LegacySQLiteStore.swift in Sources */,
|
B5D3F6451C887C0A00C7492A /* LegacySQLiteStore.swift in Sources */,
|
||||||
B596BBBB1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
B596BBBB1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
||||||
B5ECDBFF1CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
B5ECDBFF1CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
||||||
@@ -1641,7 +1647,7 @@
|
|||||||
B52FD3AA1E3B3EF10001D919 /* NSManagedObject+Logging.swift in Sources */,
|
B52FD3AA1E3B3EF10001D919 /* NSManagedObject+Logging.swift in Sources */,
|
||||||
B51FE5AB1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */,
|
B51FE5AB1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */,
|
||||||
B54A6A551BA15F2A007870FD /* FetchedResultsControllerDelegate.swift in Sources */,
|
B54A6A551BA15F2A007870FD /* FetchedResultsControllerDelegate.swift in Sources */,
|
||||||
B5D339E21E948C3600C880DE /* Attribute.swift in Sources */,
|
B5D339E21E948C3600C880DE /* Value.swift in Sources */,
|
||||||
B5A261211B64BFDB006EB6D3 /* MigrationType.swift in Sources */,
|
B5A261211B64BFDB006EB6D3 /* MigrationType.swift in Sources */,
|
||||||
B53FBA0B1CAB5E6500F0D40A /* CSCoreStore+Migrating.swift in Sources */,
|
B53FBA0B1CAB5E6500F0D40A /* CSCoreStore+Migrating.swift in Sources */,
|
||||||
B5E84F141AFF847B0064E85B /* DataStack+Querying.swift in Sources */,
|
B5E84F141AFF847B0064E85B /* DataStack+Querying.swift in Sources */,
|
||||||
@@ -1701,7 +1707,7 @@
|
|||||||
B5E84F231AFF84860064E85B /* ListMonitor.swift in Sources */,
|
B5E84F231AFF84860064E85B /* ListMonitor.swift in Sources */,
|
||||||
B5E84EF71AFF846E0064E85B /* UnsafeDataTransaction.swift in Sources */,
|
B5E84EF71AFF846E0064E85B /* UnsafeDataTransaction.swift in Sources */,
|
||||||
B56964D41B22FFAD0075EE4A /* DataStack+Migration.swift in Sources */,
|
B56964D41B22FFAD0075EE4A /* DataStack+Migration.swift in Sources */,
|
||||||
B5D339DD1E9489C700C880DE /* ManagedObjectProtocol.swift in Sources */,
|
B5D339DD1E9489C700C880DE /* DynamicObject.swift in Sources */,
|
||||||
B5A5F2661CAEC50F004AB9AF /* CSSelect.swift in Sources */,
|
B5A5F2661CAEC50F004AB9AF /* CSSelect.swift in Sources */,
|
||||||
B5ECDBE51CA6BEA300C7F112 /* CSClauseTypes.swift in Sources */,
|
B5ECDBE51CA6BEA300C7F112 /* CSClauseTypes.swift in Sources */,
|
||||||
B5519A4A1CA1F4FB002BEF78 /* CSError.swift in Sources */,
|
B5519A4A1CA1F4FB002BEF78 /* CSError.swift in Sources */,
|
||||||
@@ -1714,7 +1720,7 @@
|
|||||||
B5E222231CA4E12600BA2E95 /* CSSynchronousDataTransaction.swift in Sources */,
|
B5E222231CA4E12600BA2E95 /* CSSynchronousDataTransaction.swift in Sources */,
|
||||||
B5E84F281AFF84920064E85B /* NSManagedObject+Convenience.swift in Sources */,
|
B5E84F281AFF84920064E85B /* NSManagedObject+Convenience.swift in Sources */,
|
||||||
B51BE06A1B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift in Sources */,
|
B51BE06A1B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift in Sources */,
|
||||||
B5D339AF1E925BF200C880DE /* ObjectModel.swift in Sources */,
|
B5D339AF1E925BF200C880DE /* DynamicModel.swift in Sources */,
|
||||||
B5AEFAB51C9962AE00AD137F /* CoreStoreBridge.swift in Sources */,
|
B5AEFAB51C9962AE00AD137F /* CoreStoreBridge.swift in Sources */,
|
||||||
B5E2222A1CA51B6E00BA2E95 /* CSUnsafeDataTransaction.swift in Sources */,
|
B5E2222A1CA51B6E00BA2E95 /* CSUnsafeDataTransaction.swift in Sources */,
|
||||||
B5E84F391AFF85470064E85B /* NSManagedObjectContext+Querying.swift in Sources */,
|
B5E84F391AFF85470064E85B /* NSManagedObjectContext+Querying.swift in Sources */,
|
||||||
@@ -1728,6 +1734,7 @@
|
|||||||
B5E84F201AFF84860064E85B /* DataStack+Observing.swift in Sources */,
|
B5E84F201AFF84860064E85B /* DataStack+Observing.swift in Sources */,
|
||||||
B501FDDD1CA8D05000BE22EF /* CSSectionBy.swift in Sources */,
|
B501FDDD1CA8D05000BE22EF /* CSSectionBy.swift in Sources */,
|
||||||
B538BA771D15B3E30003A766 /* CoreStoreBridge.m in Sources */,
|
B538BA771D15B3E30003A766 /* CoreStoreBridge.m in Sources */,
|
||||||
|
B512607F1E97A18000402229 /* CoreStoreObject+Convenience.swift in Sources */,
|
||||||
B59FA0AE1CCBAC95007C9BCA /* ICloudStore.swift in Sources */,
|
B59FA0AE1CCBAC95007C9BCA /* ICloudStore.swift in Sources */,
|
||||||
B5E84EF81AFF846E0064E85B /* CoreStore+Transaction.swift in Sources */,
|
B5E84EF81AFF846E0064E85B /* CoreStore+Transaction.swift in Sources */,
|
||||||
B5E84F301AFF849C0064E85B /* NSManagedObjectContext+CoreStore.swift in Sources */,
|
B5E84F301AFF849C0064E85B /* NSManagedObjectContext+CoreStore.swift in Sources */,
|
||||||
@@ -1796,7 +1803,7 @@
|
|||||||
B529C2061CA4A2DB007E7EBD /* CSSaveResult.swift in Sources */,
|
B529C2061CA4A2DB007E7EBD /* CSSaveResult.swift in Sources */,
|
||||||
82BA18AE1C4BBD3100A0916E /* DataStack+Transaction.swift in Sources */,
|
82BA18AE1C4BBD3100A0916E /* DataStack+Transaction.swift in Sources */,
|
||||||
82BA18AB1C4BBD3100A0916E /* AsynchronousDataTransaction.swift in Sources */,
|
82BA18AB1C4BBD3100A0916E /* AsynchronousDataTransaction.swift in Sources */,
|
||||||
B5D339D91E9489AB00C880DE /* ManagedObject.swift in Sources */,
|
B5D339D91E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
||||||
82BA18CE1C4BBD7100A0916E /* FetchedResultsControllerDelegate.swift in Sources */,
|
82BA18CE1C4BBD7100A0916E /* FetchedResultsControllerDelegate.swift in Sources */,
|
||||||
B596BBBC1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
B596BBBC1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
||||||
B5ECDC011CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
B5ECDC011CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
||||||
@@ -1806,7 +1813,7 @@
|
|||||||
B52FD3AB1E3B3EF10001D919 /* NSManagedObject+Logging.swift in Sources */,
|
B52FD3AB1E3B3EF10001D919 /* NSManagedObject+Logging.swift in Sources */,
|
||||||
B51FE5AD1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */,
|
B51FE5AD1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */,
|
||||||
B5FE4DAD1C85D44E00FA6A91 /* SQLiteStore.swift in Sources */,
|
B5FE4DAD1C85D44E00FA6A91 /* SQLiteStore.swift in Sources */,
|
||||||
B5D339E31E948C3600C880DE /* Attribute.swift in Sources */,
|
B5D339E31E948C3600C880DE /* Value.swift in Sources */,
|
||||||
82BA18C51C4BBD5300A0916E /* ListObserver.swift in Sources */,
|
82BA18C51C4BBD5300A0916E /* ListObserver.swift in Sources */,
|
||||||
B53FBA0D1CAB5E6500F0D40A /* CSCoreStore+Migrating.swift in Sources */,
|
B53FBA0D1CAB5E6500F0D40A /* CSCoreStore+Migrating.swift in Sources */,
|
||||||
82BA18C21C4BBD5300A0916E /* ObjectMonitor.swift in Sources */,
|
82BA18C21C4BBD5300A0916E /* ObjectMonitor.swift in Sources */,
|
||||||
@@ -1866,7 +1873,7 @@
|
|||||||
82BA18D11C4BBD7100A0916E /* NotificationObserver.swift in Sources */,
|
82BA18D11C4BBD7100A0916E /* NotificationObserver.swift in Sources */,
|
||||||
82BA18BB1C4BBD4A00A0916E /* Where.swift in Sources */,
|
82BA18BB1C4BBD4A00A0916E /* Where.swift in Sources */,
|
||||||
B5A5F2681CAEC50F004AB9AF /* CSSelect.swift in Sources */,
|
B5A5F2681CAEC50F004AB9AF /* CSSelect.swift in Sources */,
|
||||||
B5D339DE1E9489C700C880DE /* ManagedObjectProtocol.swift in Sources */,
|
B5D339DE1E9489C700C880DE /* DynamicObject.swift in Sources */,
|
||||||
B5ECDBE71CA6BEA300C7F112 /* CSClauseTypes.swift in Sources */,
|
B5ECDBE71CA6BEA300C7F112 /* CSClauseTypes.swift in Sources */,
|
||||||
B5519A4B1CA1F4FB002BEF78 /* CSError.swift in Sources */,
|
B5519A4B1CA1F4FB002BEF78 /* CSError.swift in Sources */,
|
||||||
82BA18D71C4BBD7100A0916E /* NSManagedObjectModel+Setup.swift in Sources */,
|
82BA18D71C4BBD7100A0916E /* NSManagedObjectModel+Setup.swift in Sources */,
|
||||||
@@ -1879,7 +1886,7 @@
|
|||||||
82BA18C41C4BBD5300A0916E /* ListMonitor.swift in Sources */,
|
82BA18C41C4BBD5300A0916E /* ListMonitor.swift in Sources */,
|
||||||
82BA18BA1C4BBD4A00A0916E /* Select.swift in Sources */,
|
82BA18BA1C4BBD4A00A0916E /* Select.swift in Sources */,
|
||||||
B5AEFAB61C9962AE00AD137F /* CoreStoreBridge.swift in Sources */,
|
B5AEFAB61C9962AE00AD137F /* CoreStoreBridge.swift in Sources */,
|
||||||
B5D339B01E925BF200C880DE /* ObjectModel.swift in Sources */,
|
B5D339B01E925BF200C880DE /* DynamicModel.swift in Sources */,
|
||||||
B5E2222C1CA51B6E00BA2E95 /* CSUnsafeDataTransaction.swift in Sources */,
|
B5E2222C1CA51B6E00BA2E95 /* CSUnsafeDataTransaction.swift in Sources */,
|
||||||
82BA18A71C4BBD2900A0916E /* CoreStore+Logging.swift in Sources */,
|
82BA18A71C4BBD2900A0916E /* CoreStore+Logging.swift in Sources */,
|
||||||
82BA18D81C4BBD7100A0916E /* WeakObject.swift in Sources */,
|
82BA18D81C4BBD7100A0916E /* WeakObject.swift in Sources */,
|
||||||
@@ -1893,6 +1900,7 @@
|
|||||||
B501FDDF1CA8D05000BE22EF /* CSSectionBy.swift in Sources */,
|
B501FDDF1CA8D05000BE22EF /* CSSectionBy.swift in Sources */,
|
||||||
B59FA0B01CCBACA7007C9BCA /* ICloudStore.swift in Sources */,
|
B59FA0B01CCBACA7007C9BCA /* ICloudStore.swift in Sources */,
|
||||||
B538BA781D15B3E30003A766 /* CoreStoreBridge.m in Sources */,
|
B538BA781D15B3E30003A766 /* CoreStoreBridge.m in Sources */,
|
||||||
|
B51260801E97A18000402229 /* CoreStoreObject+Convenience.swift in Sources */,
|
||||||
82BA18D31C4BBD7100A0916E /* NSManagedObjectContext+CoreStore.swift in Sources */,
|
82BA18D31C4BBD7100A0916E /* NSManagedObjectContext+CoreStore.swift in Sources */,
|
||||||
82BA18AD1C4BBD3100A0916E /* UnsafeDataTransaction.swift in Sources */,
|
82BA18AD1C4BBD3100A0916E /* UnsafeDataTransaction.swift in Sources */,
|
||||||
B546F96A1C9AF26D00D5AC55 /* CSInMemoryStore.swift in Sources */,
|
B546F96A1C9AF26D00D5AC55 /* CSInMemoryStore.swift in Sources */,
|
||||||
@@ -1961,7 +1969,7 @@
|
|||||||
B546F9761C9C553300D5AC55 /* SetupResult.swift in Sources */,
|
B546F9761C9C553300D5AC55 /* SetupResult.swift in Sources */,
|
||||||
B53FBA161CAB63CB00F0D40A /* Progress+ObjectiveC.swift in Sources */,
|
B53FBA161CAB63CB00F0D40A /* Progress+ObjectiveC.swift in Sources */,
|
||||||
B5ECDC271CA81A3900C7F112 /* CSCoreStore+Querying.swift in Sources */,
|
B5ECDC271CA81A3900C7F112 /* CSCoreStore+Querying.swift in Sources */,
|
||||||
B5D339DB1E9489AB00C880DE /* ManagedObject.swift in Sources */,
|
B5D339DB1E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
||||||
B52DD1951BE1F92500949AFE /* CoreStoreError.swift in Sources */,
|
B52DD1951BE1F92500949AFE /* CoreStoreError.swift in Sources */,
|
||||||
B596BBBE1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
B596BBBE1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
||||||
B546F9601C9A12B800D5AC55 /* CSSQliteStore.swift in Sources */,
|
B546F9601C9A12B800D5AC55 /* CSSQliteStore.swift in Sources */,
|
||||||
@@ -1971,7 +1979,7 @@
|
|||||||
B52FD3AD1E3B3EF10001D919 /* NSManagedObject+Logging.swift in Sources */,
|
B52FD3AD1E3B3EF10001D919 /* NSManagedObject+Logging.swift in Sources */,
|
||||||
B5ECDC2D1CA81CC700C7F112 /* CSDataStack+Transaction.swift in Sources */,
|
B5ECDC2D1CA81CC700C7F112 /* CSDataStack+Transaction.swift in Sources */,
|
||||||
B5D7A5BA1CA3BF8F005C752B /* CSInto.swift in Sources */,
|
B5D7A5BA1CA3BF8F005C752B /* CSInto.swift in Sources */,
|
||||||
B5D339E51E948C3600C880DE /* Attribute.swift in Sources */,
|
B5D339E51E948C3600C880DE /* Value.swift in Sources */,
|
||||||
B5A5F26A1CAEC50F004AB9AF /* CSSelect.swift in Sources */,
|
B5A5F26A1CAEC50F004AB9AF /* CSSelect.swift in Sources */,
|
||||||
B5220E1B1D13079B009BC71E /* CSCoreStore+Observing.swift in Sources */,
|
B5220E1B1D13079B009BC71E /* CSCoreStore+Observing.swift in Sources */,
|
||||||
B5FEC1911C9166E700532541 /* NSPersistentStore+Setup.swift in Sources */,
|
B5FEC1911C9166E700532541 /* NSPersistentStore+Setup.swift in Sources */,
|
||||||
@@ -2031,7 +2039,7 @@
|
|||||||
B52DD1CA1BE1F94600949AFE /* NSManagedObjectModel+Setup.swift in Sources */,
|
B52DD1CA1BE1F94600949AFE /* NSManagedObjectModel+Setup.swift in Sources */,
|
||||||
B52DD1A41BE1F92F00949AFE /* ImportableObject.swift in Sources */,
|
B52DD1A41BE1F92F00949AFE /* ImportableObject.swift in Sources */,
|
||||||
B5220E161D13067C009BC71E /* ObjectMonitor.swift in Sources */,
|
B5220E161D13067C009BC71E /* ObjectMonitor.swift in Sources */,
|
||||||
B5D339E01E9489C700C880DE /* ManagedObjectProtocol.swift in Sources */,
|
B5D339E01E9489C700C880DE /* DynamicObject.swift in Sources */,
|
||||||
B52DD1AE1BE1F93900949AFE /* OrderBy.swift in Sources */,
|
B52DD1AE1BE1F93900949AFE /* OrderBy.swift in Sources */,
|
||||||
B52DD1BA1BE1F94000949AFE /* MigrationChain.swift in Sources */,
|
B52DD1BA1BE1F94000949AFE /* MigrationChain.swift in Sources */,
|
||||||
B50392FB1C479640009900CA /* NSManagedObject+Transaction.swift in Sources */,
|
B50392FB1C479640009900CA /* NSManagedObject+Transaction.swift in Sources */,
|
||||||
@@ -2044,7 +2052,7 @@
|
|||||||
B5220E1A1D130791009BC71E /* CoreStoreFetchedResultsController.swift in Sources */,
|
B5220E1A1D130791009BC71E /* CoreStoreFetchedResultsController.swift in Sources */,
|
||||||
B53FBA0F1CAB5E6500F0D40A /* CSCoreStore+Migrating.swift in Sources */,
|
B53FBA0F1CAB5E6500F0D40A /* CSCoreStore+Migrating.swift in Sources */,
|
||||||
B59FA0B21CCBACA8007C9BCA /* ICloudStore.swift in Sources */,
|
B59FA0B21CCBACA8007C9BCA /* ICloudStore.swift in Sources */,
|
||||||
B5D339B21E925BF200C880DE /* ObjectModel.swift in Sources */,
|
B5D339B21E925BF200C880DE /* DynamicModel.swift in Sources */,
|
||||||
B52DD19A1BE1F92800949AFE /* CoreStore+Logging.swift in Sources */,
|
B52DD19A1BE1F92800949AFE /* CoreStore+Logging.swift in Sources */,
|
||||||
B52DD1A71BE1F93200949AFE /* BaseDataTransaction+Querying.swift in Sources */,
|
B52DD1A71BE1F93200949AFE /* BaseDataTransaction+Querying.swift in Sources */,
|
||||||
B546F96C1C9AF26D00D5AC55 /* CSInMemoryStore.swift in Sources */,
|
B546F96C1C9AF26D00D5AC55 /* CSInMemoryStore.swift in Sources */,
|
||||||
@@ -2058,6 +2066,7 @@
|
|||||||
B5220E181D130711009BC71E /* ObjectObserver.swift in Sources */,
|
B5220E181D130711009BC71E /* ObjectObserver.swift in Sources */,
|
||||||
B5220E251D13088E009BC71E /* ListObserver.swift in Sources */,
|
B5220E251D13088E009BC71E /* ListObserver.swift in Sources */,
|
||||||
B538BA7A1D15B3E30003A766 /* CoreStoreBridge.m in Sources */,
|
B538BA7A1D15B3E30003A766 /* CoreStoreBridge.m in Sources */,
|
||||||
|
B51260821E97A18000402229 /* CoreStoreObject+Convenience.swift in Sources */,
|
||||||
B52DD1A01BE1F92C00949AFE /* UnsafeDataTransaction.swift in Sources */,
|
B52DD1A01BE1F92C00949AFE /* UnsafeDataTransaction.swift in Sources */,
|
||||||
B5ECDC331CA81CDC00C7F112 /* CSCoreStore+Transaction.swift in Sources */,
|
B5ECDC331CA81CDC00C7F112 /* CSCoreStore+Transaction.swift in Sources */,
|
||||||
B52DD1BB1BE1F94000949AFE /* MigrationType.swift in Sources */,
|
B52DD1BB1BE1F94000949AFE /* MigrationType.swift in Sources */,
|
||||||
@@ -2126,7 +2135,7 @@
|
|||||||
B529C2071CA4A2DC007E7EBD /* CSSaveResult.swift in Sources */,
|
B529C2071CA4A2DC007E7EBD /* CSSaveResult.swift in Sources */,
|
||||||
B563219D1BD65216006C9394 /* DataStack+Observing.swift in Sources */,
|
B563219D1BD65216006C9394 /* DataStack+Observing.swift in Sources */,
|
||||||
B56321961BD65216006C9394 /* From.swift in Sources */,
|
B56321961BD65216006C9394 /* From.swift in Sources */,
|
||||||
B5D339DA1E9489AB00C880DE /* ManagedObject.swift in Sources */,
|
B5D339DA1E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
||||||
B5ECDC021CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
B5ECDC021CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
||||||
B596BBBD1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
B596BBBD1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
||||||
B5ECDC081CA8138100C7F112 /* CSOrderBy.swift in Sources */,
|
B5ECDC081CA8138100C7F112 /* CSOrderBy.swift in Sources */,
|
||||||
@@ -2136,7 +2145,7 @@
|
|||||||
B52FD3AC1E3B3EF10001D919 /* NSManagedObject+Logging.swift in Sources */,
|
B52FD3AC1E3B3EF10001D919 /* NSManagedObject+Logging.swift in Sources */,
|
||||||
B51FE5AE1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */,
|
B51FE5AE1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */,
|
||||||
B563218C1BD65216006C9394 /* DataStack+Transaction.swift in Sources */,
|
B563218C1BD65216006C9394 /* DataStack+Transaction.swift in Sources */,
|
||||||
B5D339E41E948C3600C880DE /* Attribute.swift in Sources */,
|
B5D339E41E948C3600C880DE /* Value.swift in Sources */,
|
||||||
B53FBA0E1CAB5E6500F0D40A /* CSCoreStore+Migrating.swift in Sources */,
|
B53FBA0E1CAB5E6500F0D40A /* CSCoreStore+Migrating.swift in Sources */,
|
||||||
B563219E1BD65216006C9394 /* CoreStore+Observing.swift in Sources */,
|
B563219E1BD65216006C9394 /* CoreStore+Observing.swift in Sources */,
|
||||||
B5D7A5B91CA3BF8F005C752B /* CSInto.swift in Sources */,
|
B5D7A5B91CA3BF8F005C752B /* CSInto.swift in Sources */,
|
||||||
@@ -2196,7 +2205,7 @@
|
|||||||
B563219A1BD65216006C9394 /* GroupBy.swift in Sources */,
|
B563219A1BD65216006C9394 /* GroupBy.swift in Sources */,
|
||||||
B5ECDBE81CA6BEA300C7F112 /* CSClauseTypes.swift in Sources */,
|
B5ECDBE81CA6BEA300C7F112 /* CSClauseTypes.swift in Sources */,
|
||||||
B5A5F2691CAEC50F004AB9AF /* CSSelect.swift in Sources */,
|
B5A5F2691CAEC50F004AB9AF /* CSSelect.swift in Sources */,
|
||||||
B5D339DF1E9489C700C880DE /* ManagedObjectProtocol.swift in Sources */,
|
B5D339DF1E9489C700C880DE /* DynamicObject.swift in Sources */,
|
||||||
B5519A4C1CA1F4FB002BEF78 /* CSError.swift in Sources */,
|
B5519A4C1CA1F4FB002BEF78 /* CSError.swift in Sources */,
|
||||||
B563219B1BD65216006C9394 /* Tweak.swift in Sources */,
|
B563219B1BD65216006C9394 /* Tweak.swift in Sources */,
|
||||||
B56321B51BD6521C006C9394 /* NSManagedObjectModel+Setup.swift in Sources */,
|
B56321B51BD6521C006C9394 /* NSManagedObjectModel+Setup.swift in Sources */,
|
||||||
@@ -2209,7 +2218,7 @@
|
|||||||
B56321A21BD65216006C9394 /* ListObserver.swift in Sources */,
|
B56321A21BD65216006C9394 /* ListObserver.swift in Sources */,
|
||||||
B563218A1BD65216006C9394 /* SynchronousDataTransaction.swift in Sources */,
|
B563218A1BD65216006C9394 /* SynchronousDataTransaction.swift in Sources */,
|
||||||
B5AEFAB71C9962AE00AD137F /* CoreStoreBridge.swift in Sources */,
|
B5AEFAB71C9962AE00AD137F /* CoreStoreBridge.swift in Sources */,
|
||||||
B5D339B11E925BF200C880DE /* ObjectModel.swift in Sources */,
|
B5D339B11E925BF200C880DE /* DynamicModel.swift in Sources */,
|
||||||
B5E2222D1CA51B6E00BA2E95 /* CSUnsafeDataTransaction.swift in Sources */,
|
B5E2222D1CA51B6E00BA2E95 /* CSUnsafeDataTransaction.swift in Sources */,
|
||||||
B563219F1BD65216006C9394 /* ObjectMonitor.swift in Sources */,
|
B563219F1BD65216006C9394 /* ObjectMonitor.swift in Sources */,
|
||||||
B56321B61BD6521C006C9394 /* WeakObject.swift in Sources */,
|
B56321B61BD6521C006C9394 /* WeakObject.swift in Sources */,
|
||||||
@@ -2223,6 +2232,7 @@
|
|||||||
B501FDE01CA8D05000BE22EF /* CSSectionBy.swift in Sources */,
|
B501FDE01CA8D05000BE22EF /* CSSectionBy.swift in Sources */,
|
||||||
B59FA0B11CCBACA7007C9BCA /* ICloudStore.swift in Sources */,
|
B59FA0B11CCBACA7007C9BCA /* ICloudStore.swift in Sources */,
|
||||||
B538BA791D15B3E30003A766 /* CoreStoreBridge.m in Sources */,
|
B538BA791D15B3E30003A766 /* CoreStoreBridge.m in Sources */,
|
||||||
|
B51260811E97A18000402229 /* CoreStoreObject+Convenience.swift in Sources */,
|
||||||
B56321B11BD6521C006C9394 /* NSManagedObjectContext+CoreStore.swift in Sources */,
|
B56321B11BD6521C006C9394 /* NSManagedObjectContext+CoreStore.swift in Sources */,
|
||||||
B563218D1BD65216006C9394 /* CoreStore+Transaction.swift in Sources */,
|
B563218D1BD65216006C9394 /* CoreStore+Transaction.swift in Sources */,
|
||||||
B546F96B1C9AF26D00D5AC55 /* CSInMemoryStore.swift in Sources */,
|
B546F96B1C9AF26D00D5AC55 /* CSInMemoryStore.swift in Sources */,
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class Palette: NSManagedObject {
|
|||||||
get {
|
get {
|
||||||
|
|
||||||
let KVCKey = #keyPath(Palette.colorName)
|
let KVCKey = #keyPath(Palette.colorName)
|
||||||
if let colorName = self.accessValueForKVCKey(KVCKey) as? String {
|
if let colorName = self.getValue(forKvcKey: KVCKey) as? String {
|
||||||
|
|
||||||
return colorName
|
return colorName
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ class Palette: NSManagedObject {
|
|||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
|
||||||
self.setValue(newValue, forKVCKey: #keyPath(Palette.colorName))
|
self.setValue(newValue, forKvcKey: #keyPath(Palette.colorName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class MigrationsDemoViewController: UIViewController, ListObserver, UITableViewD
|
|||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
private typealias ModelMetadata = (label: String, version: String, entityType: AnyClass, migrationChain: MigrationChain)
|
private typealias ModelMetadata = (label: String, version: String, entityType: NSManagedObject.Type, migrationChain: MigrationChain)
|
||||||
|
|
||||||
private let models: [ModelMetadata] = [
|
private let models: [ModelMetadata] = [
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -27,10 +27,9 @@
|
|||||||
import CoreStore
|
import CoreStore
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - ConvenienceTests
|
// MARK: - ConvenienceTests
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
class ConvenienceTests: BaseTestCase {
|
class ConvenienceTests: BaseTestCase {
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
@@ -90,5 +89,3 @@ class ConvenienceTests: BaseTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -2,42 +2,62 @@
|
|||||||
// DynamicModelTests.swift
|
// DynamicModelTests.swift
|
||||||
// CoreStore
|
// CoreStore
|
||||||
//
|
//
|
||||||
// Created by John Estropia on 2017/04/03.
|
// Copyright © 2017 John Rommel Estropia
|
||||||
// Copyright © 2017 John Rommel Estropia. All rights reserved.
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
import CoreData
|
@testable
|
||||||
|
import CoreStore
|
||||||
@testable import CoreStore
|
|
||||||
|
|
||||||
|
|
||||||
class Animal: ManagedObject {
|
class Animal: CoreStoreObject {
|
||||||
|
|
||||||
let species = Attribute.Required<String>("species", default: "Swift")
|
let species = Value.Required<String>("species", default: "Swift")
|
||||||
let master = Relationship.ToOne<Person>("master", inverse: { $0.pet })
|
let master = Relationship.ToOne<Person>("master")
|
||||||
}
|
}
|
||||||
|
|
||||||
class Dog: Animal {
|
class Dog: Animal {
|
||||||
|
|
||||||
let nickname = Attribute.Optional<String>("nickname")
|
let nickname = Value.Optional<String>("nickname")
|
||||||
let age = Attribute.Required<Int>("age", default: 1)
|
let age = Value.Required<Int>("age", default: 1)
|
||||||
|
let friends = Relationship.ToManyUnordered<Dog>("friends")
|
||||||
|
let friends2 = Relationship.ToManyUnordered<Dog>("friends2", inverse: { $0.friends })
|
||||||
}
|
}
|
||||||
|
|
||||||
class Person: ManagedObject {
|
class Person: CoreStoreObject {
|
||||||
|
|
||||||
let name = Attribute.Required<String>("name")
|
let name = Value.Required<String>("name")
|
||||||
let pet = Relationship.ToOne<Animal>("pet")
|
let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - DynamicModelTests
|
||||||
|
|
||||||
class DynamicModelTests: BaseTestDataTestCase {
|
class DynamicModelTests: BaseTestDataTestCase {
|
||||||
|
|
||||||
func testDynamicModels_CanBeDeclaredCorrectly() {
|
func testDynamicModels_CanBeDeclaredCorrectly() {
|
||||||
|
|
||||||
let dataStack = DataStack(
|
let dataStack = DataStack(
|
||||||
dynamicModel: ObjectModel(
|
dynamicModel: DynamicModel(
|
||||||
version: "V1",
|
version: "V1",
|
||||||
entities: [
|
entities: [
|
||||||
Entity<Animal>("Animal"),
|
Entity<Animal>("Animal"),
|
||||||
@@ -57,26 +77,28 @@ class DynamicModelTests: BaseTestDataTestCase {
|
|||||||
let k3 = Dog.keyPath({ $0.nickname })
|
let k3 = Dog.keyPath({ $0.nickname })
|
||||||
XCTAssertEqual(k3, "nickname")
|
XCTAssertEqual(k3, "nickname")
|
||||||
|
|
||||||
let expectation = self.expectation(description: "done")
|
let updateDone = self.expectation(description: "update-done")
|
||||||
|
let fetchDone = self.expectation(description: "fetch-done")
|
||||||
stack.perform(
|
stack.perform(
|
||||||
asynchronous: { (transaction) in
|
asynchronous: { (transaction) in
|
||||||
|
|
||||||
let animal = transaction.create(Into<Animal>())
|
let animal = transaction.create(Into<Animal>())
|
||||||
XCTAssertEqual(animal.species*, "Swift")
|
XCTAssertEqual(animal.species.value, "Swift")
|
||||||
XCTAssertTrue(type(of: animal.species*) == String.self)
|
XCTAssertTrue(type(of: animal.species.value) == String.self)
|
||||||
|
|
||||||
animal.species .= "Sparrow"
|
animal.species .= "Sparrow"
|
||||||
XCTAssertEqual(animal.species*, "Sparrow")
|
XCTAssertEqual(animal.species.value, "Sparrow")
|
||||||
|
|
||||||
let dog = transaction.create(Into<Dog>())
|
let dog = transaction.create(Into<Dog>())
|
||||||
XCTAssertEqual(dog.species*, "Swift")
|
XCTAssertEqual(dog.species.value, "Swift")
|
||||||
XCTAssertEqual(dog.nickname*, nil)
|
XCTAssertEqual(dog.nickname.value, nil)
|
||||||
|
XCTAssertEqual(dog.age.value, 1)
|
||||||
|
|
||||||
dog.species .= "Dog"
|
dog.species .= "Dog"
|
||||||
XCTAssertEqual(dog.species*, "Dog")
|
XCTAssertEqual(dog.species.value, "Dog")
|
||||||
|
|
||||||
dog.nickname .= "Spot"
|
dog.nickname .= "Spot"
|
||||||
XCTAssertEqual(dog.nickname*, "Spot")
|
XCTAssertEqual(dog.nickname.value, "Spot")
|
||||||
|
|
||||||
let person = transaction.create(Into<Person>())
|
let person = transaction.create(Into<Person>())
|
||||||
XCTAssertNil(person.pet.value)
|
XCTAssertNil(person.pet.value)
|
||||||
@@ -89,7 +111,7 @@ class DynamicModelTests: BaseTestDataTestCase {
|
|||||||
},
|
},
|
||||||
success: {
|
success: {
|
||||||
|
|
||||||
print("done")
|
updateDone.fulfill()
|
||||||
},
|
},
|
||||||
failure: { _ in
|
failure: { _ in
|
||||||
|
|
||||||
@@ -104,15 +126,15 @@ class DynamicModelTests: BaseTestDataTestCase {
|
|||||||
|
|
||||||
let bird = transaction.fetchOne(From<Animal>(), p1)
|
let bird = transaction.fetchOne(From<Animal>(), p1)
|
||||||
XCTAssertNotNil(bird)
|
XCTAssertNotNil(bird)
|
||||||
XCTAssertEqual(bird!.species*, "Sparrow")
|
XCTAssertEqual(bird!.species.value, "Sparrow")
|
||||||
|
|
||||||
let p2 = Dog.where({ $0.nickname == "Spot" })
|
let p2 = Dog.where({ $0.nickname == "Spot" })
|
||||||
XCTAssertEqual(p2.predicate, NSPredicate(format: "%K == %@", "nickname", "Spot"))
|
XCTAssertEqual(p2.predicate, NSPredicate(format: "%K == %@", "nickname", "Spot"))
|
||||||
|
|
||||||
let dog = transaction.fetchOne(From<Dog>(), p2)
|
let dog = transaction.fetchOne(From<Dog>(), p2)
|
||||||
XCTAssertNotNil(dog)
|
XCTAssertNotNil(dog)
|
||||||
XCTAssertEqual(dog!.nickname*, "Spot")
|
XCTAssertEqual(dog!.nickname.value, "Spot")
|
||||||
XCTAssertEqual(dog!.species*, "Dog")
|
XCTAssertEqual(dog!.species.value, "Dog")
|
||||||
|
|
||||||
let person = transaction.fetchOne(From<Person>())
|
let person = transaction.fetchOne(From<Person>())
|
||||||
XCTAssertNotNil(person)
|
XCTAssertNotNil(person)
|
||||||
@@ -123,7 +145,7 @@ class DynamicModelTests: BaseTestDataTestCase {
|
|||||||
},
|
},
|
||||||
success: {
|
success: {
|
||||||
|
|
||||||
expectation.fulfill()
|
fetchDone.fulfill()
|
||||||
withExtendedLifetime(stack, {})
|
withExtendedLifetime(stack, {})
|
||||||
},
|
},
|
||||||
failure: { _ in
|
failure: { _ in
|
||||||
|
|||||||
@@ -29,27 +29,11 @@ import XCTest
|
|||||||
import CoreStore
|
import CoreStore
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - ListObserverTests
|
// MARK: - ListObserverTests
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
class ListObserverTests: BaseTestDataTestCase {
|
class ListObserverTests: BaseTestDataTestCase {
|
||||||
|
|
||||||
@objc
|
|
||||||
dynamic func test_ThatListObservers_CanDowncast() {
|
|
||||||
|
|
||||||
self.prepareStack { (stack) in
|
|
||||||
|
|
||||||
let monitor = stack.monitorSectionedList(
|
|
||||||
From<TestEntity1>(),
|
|
||||||
SectionBy(#keyPath(TestEntity1.testBoolean)),
|
|
||||||
OrderBy(.ascending(#keyPath(TestEntity1.testBoolean)), .ascending(#keyPath(TestEntity1.testEntityID)))
|
|
||||||
)
|
|
||||||
let downcast = monitor.downcast()
|
|
||||||
XCTAssertTrue(monitor == downcast)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
dynamic func test_ThatListObservers_CanReceiveInsertNotifications() {
|
dynamic func test_ThatListObservers_CanReceiveInsertNotifications() {
|
||||||
|
|
||||||
@@ -118,8 +102,8 @@ class ListObserverTests: BaseTestDataTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
let indexPath = userInfo?["indexPath"] as? NSIndexPath
|
let indexPath = userInfo?["indexPath"] as? NSIndexPath
|
||||||
XCTAssertEqual(indexPath?.section, 0)
|
XCTAssertEqual(indexPath?.index(atPosition: 0), 0)
|
||||||
XCTAssertEqual(indexPath?.row, 0)
|
XCTAssertEqual(indexPath?.index(atPosition: 1), 0)
|
||||||
|
|
||||||
let object = userInfo?["object"] as? TestEntity1
|
let object = userInfo?["object"] as? TestEntity1
|
||||||
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
|
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
|
||||||
@@ -236,8 +220,8 @@ class ListObserverTests: BaseTestDataTestCase {
|
|||||||
switch object?.testEntityID {
|
switch object?.testEntityID {
|
||||||
|
|
||||||
case NSNumber(value: 101)?:
|
case NSNumber(value: 101)?:
|
||||||
XCTAssertEqual(indexPath?.section, 1)
|
XCTAssertEqual(indexPath?.index(atPosition: 0), 1)
|
||||||
XCTAssertEqual(indexPath?.row, 0)
|
XCTAssertEqual(indexPath?.index(atPosition: 1), 0)
|
||||||
|
|
||||||
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
|
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
|
||||||
XCTAssertEqual(object?.testNumber, NSNumber(value: 11))
|
XCTAssertEqual(object?.testNumber, NSNumber(value: 11))
|
||||||
@@ -247,8 +231,8 @@ class ListObserverTests: BaseTestDataTestCase {
|
|||||||
XCTAssertEqual(object?.testDate, self.dateFormatter.date(from: "2000-01-11T00:00:00Z")!)
|
XCTAssertEqual(object?.testDate, self.dateFormatter.date(from: "2000-01-11T00:00:00Z")!)
|
||||||
|
|
||||||
case NSNumber(value: 102)?:
|
case NSNumber(value: 102)?:
|
||||||
XCTAssertEqual(indexPath?.section, 0)
|
XCTAssertEqual(indexPath?.index(atPosition: 0), 0)
|
||||||
XCTAssertEqual(indexPath?.row, 0)
|
XCTAssertEqual(indexPath?.index(atPosition: 1), 0)
|
||||||
|
|
||||||
XCTAssertEqual(object?.testBoolean, NSNumber(value: false))
|
XCTAssertEqual(object?.testBoolean, NSNumber(value: false))
|
||||||
XCTAssertEqual(object?.testNumber, NSNumber(value: 22))
|
XCTAssertEqual(object?.testNumber, NSNumber(value: 22))
|
||||||
@@ -376,12 +360,12 @@ class ListObserverTests: BaseTestDataTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
let fromIndexPath = userInfo?["fromIndexPath"] as? NSIndexPath
|
let fromIndexPath = userInfo?["fromIndexPath"] as? NSIndexPath
|
||||||
XCTAssertEqual(fromIndexPath?.section, 0)
|
XCTAssertEqual(fromIndexPath?.index(atPosition: 0), 0)
|
||||||
XCTAssertEqual(fromIndexPath?.row, 0)
|
XCTAssertEqual(fromIndexPath?.index(atPosition: 1), 0)
|
||||||
|
|
||||||
let toIndexPath = userInfo?["toIndexPath"] as? NSIndexPath
|
let toIndexPath = userInfo?["toIndexPath"] as? NSIndexPath
|
||||||
XCTAssertEqual(toIndexPath?.section, 1)
|
XCTAssertEqual(toIndexPath?.index(atPosition: 0), 1)
|
||||||
XCTAssertEqual(toIndexPath?.row, 1)
|
XCTAssertEqual(toIndexPath?.index(atPosition: 1), 1)
|
||||||
|
|
||||||
let object = userInfo?["object"] as? TestEntity1
|
let object = userInfo?["object"] as? TestEntity1
|
||||||
XCTAssertEqual(object?.testEntityID, NSNumber(value: 102))
|
XCTAssertEqual(object?.testEntityID, NSNumber(value: 102))
|
||||||
@@ -488,7 +472,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
|||||||
let indexPath = userInfo?["indexPath"] as? NSIndexPath
|
let indexPath = userInfo?["indexPath"] as? NSIndexPath
|
||||||
|
|
||||||
XCTAssertEqual(indexPath?.section, 0)
|
XCTAssertEqual(indexPath?.section, 0)
|
||||||
XCTAssert(indexPath?.row == 0 || indexPath?.row == 1)
|
XCTAssert(indexPath?.index(atPosition: 1) == 0 || indexPath?.index(atPosition: 1) == 1)
|
||||||
|
|
||||||
let object = userInfo?["object"] as? TestEntity1
|
let object = userInfo?["object"] as? TestEntity1
|
||||||
XCTAssertEqual(object?.isDeleted, true)
|
XCTAssertEqual(object?.isDeleted, true)
|
||||||
@@ -571,6 +555,7 @@ class ListObserverTests: BaseTestDataTestCase {
|
|||||||
|
|
||||||
// MARK: TestListObserver
|
// MARK: TestListObserver
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
class TestListObserver: ListSectionObserver {
|
class TestListObserver: ListSectionObserver {
|
||||||
|
|
||||||
// MARK: ListObserver
|
// MARK: ListObserver
|
||||||
@@ -693,5 +678,3 @@ class TestListObserver: ListSectionObserver {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -29,31 +29,10 @@ import XCTest
|
|||||||
import CoreStore
|
import CoreStore
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - ObjectObserverTests
|
// MARK: - ObjectObserverTests
|
||||||
|
|
||||||
class ObjectObserverTests: BaseTestDataTestCase {
|
@available(OSX 10.12, *)
|
||||||
|
class ObjectObserverTests: BaseTestDataTestCase {
|
||||||
@objc
|
|
||||||
dynamic func test_ThatObjectObservers_CanDowncast() {
|
|
||||||
|
|
||||||
self.prepareStack { (stack) in
|
|
||||||
|
|
||||||
self.prepareTestDataForStack(stack)
|
|
||||||
|
|
||||||
guard let object = stack.fetchOne(
|
|
||||||
From<TestEntity1>(),
|
|
||||||
Where(#keyPath(TestEntity1.testEntityID), isEqualTo: 101)) else {
|
|
||||||
|
|
||||||
XCTFail()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let monitor = stack.monitorObject(object)
|
|
||||||
let downcast = monitor.downcast()
|
|
||||||
XCTAssertTrue(monitor == downcast)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
dynamic func test_ThatObjectObservers_CanReceiveUpdateNotifications() {
|
dynamic func test_ThatObjectObservers_CanReceiveUpdateNotifications() {
|
||||||
@@ -224,6 +203,7 @@ import CoreStore
|
|||||||
|
|
||||||
// MARK: TestObjectObserver
|
// MARK: TestObjectObserver
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
class TestObjectObserver: ObjectObserver {
|
class TestObjectObserver: ObjectObserver {
|
||||||
|
|
||||||
typealias ObjectEntityType = TestEntity1
|
typealias ObjectEntityType = TestEntity1
|
||||||
@@ -262,5 +242,3 @@ class TestObjectObserver: ObjectObserver {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -29,10 +29,9 @@ import XCTest
|
|||||||
import CoreStore
|
import CoreStore
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
//MARK: - SectionByTests
|
//MARK: - SectionByTests
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
final class SectionByTests: XCTestCase {
|
final class SectionByTests: XCTestCase {
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
@@ -53,5 +52,3 @@ final class SectionByTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -386,8 +386,8 @@ final class TransactionTests: BaseTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
@objc
|
@objc
|
||||||
dynamic func test_ThatSynchronousTransactions_CanCommitWithoutWaitingForMerges() {
|
dynamic func test_ThatSynchronousTransactions_CanCommitWithoutWaitingForMerges() {
|
||||||
|
|
||||||
@@ -432,8 +432,8 @@ final class TransactionTests: BaseTestCase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
let indexPath = userInfo?["indexPath"] as? NSIndexPath
|
let indexPath = userInfo?["indexPath"] as? NSIndexPath
|
||||||
XCTAssertEqual(indexPath?.section, 0)
|
XCTAssertEqual(indexPath?.index(atPosition: 0), 0)
|
||||||
XCTAssertEqual(indexPath?.row, 0)
|
XCTAssertEqual(indexPath?.index(atPosition: 1), 0)
|
||||||
|
|
||||||
let object = userInfo?["object"] as? TestEntity1
|
let object = userInfo?["object"] as? TestEntity1
|
||||||
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
|
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
|
||||||
@@ -489,7 +489,6 @@ final class TransactionTests: BaseTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
dynamic func test_ThatAsynchronousTransactions_CanPerformCRUDs() {
|
dynamic func test_ThatAsynchronousTransactions_CanPerformCRUDs() {
|
||||||
|
|||||||
99
Sources/Convenience/CoreStoreObject+Convenience.swift
Normal file
99
Sources/Convenience/CoreStoreObject+Convenience.swift
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
//
|
||||||
|
// CoreStoreObject+Convenience.swift
|
||||||
|
// CoreStore
|
||||||
|
//
|
||||||
|
// Copyright © 2017 John Rommel Estropia
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - CoreStoreObject
|
||||||
|
|
||||||
|
public extension CoreStoreObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Exposes a `FetchableSource` that can fetch sibling objects of this `CoreStoreObject` instance. This may be the `DataStack`, a `BaseDataTransaction`, the `NSManagedObjectContext` itself, or `nil` if the obejct's parent is already deallocated.
|
||||||
|
- Warning: Future implementations may change the instance returned by this method depending on the timing or condition that `fetchSource()` was called. Do not make assumptions that the instance will be a specific instance. If the `NSManagedObjectContext` instance is desired, use the `FetchableSource.unsafeContext()` method to get the correct instance. Also, do not assume that the `fetchSource()` and `querySource()` return the same instance all the time.
|
||||||
|
- returns: a `FetchableSource` that can fetch sibling objects of this `CoreStoreObject` instance. This may be the `DataStack`, a `BaseDataTransaction`, the `NSManagedObjectContext` itself, or `nil` if the object's parent is already deallocated.
|
||||||
|
*/
|
||||||
|
@nonobjc
|
||||||
|
public func fetchSource() -> FetchableSource? {
|
||||||
|
|
||||||
|
guard let context = self.rawObject!.managedObjectContext else {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if context.isTransactionContext {
|
||||||
|
|
||||||
|
return context.parentTransaction
|
||||||
|
}
|
||||||
|
if context.isDataStackContext {
|
||||||
|
|
||||||
|
return context.parentStack
|
||||||
|
}
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Exposes a `QueryableSource` that can query attributes and aggregate values. This may be the `DataStack`, a `BaseDataTransaction`, the `NSManagedObjectContext` itself, or `nil` if the obejct's parent is already deallocated.
|
||||||
|
- Warning: Future implementations may change the instance returned by this method depending on the timing or condition that `querySource()` was called. Do not make assumptions that the instance will be a specific instance. If the `NSManagedObjectContext` instance is desired, use the `QueryableSource.unsafeContext()` method to get the correct instance. Also, do not assume that the `fetchSource()` and `querySource()` return the same instance all the time.
|
||||||
|
- returns: a `QueryableSource` that can query attributes and aggregate values. This may be the `DataStack`, a `BaseDataTransaction`, the `NSManagedObjectContext` itself, or `nil` if the object's parent is already deallocated.
|
||||||
|
*/
|
||||||
|
@nonobjc
|
||||||
|
public func querySource() -> QueryableSource? {
|
||||||
|
|
||||||
|
guard let context = self.rawObject!.managedObjectContext else {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if context.isTransactionContext {
|
||||||
|
|
||||||
|
return context.parentTransaction
|
||||||
|
}
|
||||||
|
if context.isDataStackContext {
|
||||||
|
|
||||||
|
return context.parentStack
|
||||||
|
}
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Re-faults the object to use the latest values from the persistent store
|
||||||
|
*/
|
||||||
|
@nonobjc
|
||||||
|
public func refreshAsFault() {
|
||||||
|
|
||||||
|
let rawObject = self.rawObject!
|
||||||
|
rawObject.managedObjectContext?.refresh(rawObject, mergeChanges: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Re-faults the object to use the latest values from the persistent store and merges previously pending changes back
|
||||||
|
*/
|
||||||
|
@nonobjc
|
||||||
|
public func refreshAndMerge() {
|
||||||
|
|
||||||
|
let rawObject = self.rawObject!
|
||||||
|
rawObject.managedObjectContext?.refresh(rawObject, mergeChanges: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,10 +26,10 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - DataStack
|
// MARK: - DataStack
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension DataStack {
|
public extension DataStack {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,6 +114,7 @@ public extension DataStack {
|
|||||||
|
|
||||||
// MARK: - UnsafeDataTransaction
|
// MARK: - UnsafeDataTransaction
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension UnsafeDataTransaction {
|
public extension UnsafeDataTransaction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,6 +200,7 @@ public extension UnsafeDataTransaction {
|
|||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
fileprivate func createFRC<T: NSManagedObject>(fromContext context: NSManagedObjectContext, from: From<T>? = nil, sectionBy: SectionBy? = nil, fetchClauses: [FetchClause]) -> NSFetchedResultsController<T> {
|
fileprivate func createFRC<T: NSManagedObject>(fromContext context: NSManagedObjectContext, from: From<T>? = nil, sectionBy: SectionBy? = nil, fetchClauses: [FetchClause]) -> NSFetchedResultsController<T> {
|
||||||
|
|
||||||
let controller = CoreStoreFetchedResultsController(
|
let controller = CoreStoreFetchedResultsController(
|
||||||
@@ -218,5 +220,3 @@ fileprivate func createFRC<T: NSManagedObject>(fromContext context: NSManagedObj
|
|||||||
)
|
)
|
||||||
return controller.dynamicCast()
|
return controller.dynamicCast()
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -77,50 +77,43 @@ public extension NSManagedObject {
|
|||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@nonobjc @inline(__always)
|
||||||
Provides a convenience wrapper for accessing `primitiveValueForKey(...)` with proper calls to `willAccessValueForKey(...)` and `didAccessValueForKey(...)`. This is useful when implementing accessor methods for transient attributes.
|
public func getValue(forKvcKey kvcKey: KeyPath) -> Any? {
|
||||||
|
|
||||||
- parameter KVCKey: the KVC key
|
self.willAccessValue(forKey: kvcKey)
|
||||||
- returns: the primitive value for the KVC key
|
|
||||||
*/
|
|
||||||
@nonobjc
|
|
||||||
public func accessValueForKVCKey(_ KVCKey: KeyPath) -> Any? {
|
|
||||||
|
|
||||||
self.willAccessValue(forKey: KVCKey)
|
|
||||||
defer {
|
defer {
|
||||||
|
|
||||||
self.didAccessValue(forKey: KVCKey)
|
self.didAccessValue(forKey: kvcKey)
|
||||||
}
|
}
|
||||||
return self.primitiveValue(forKey: KVCKey)
|
return self.primitiveValue(forKey: kvcKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@nonobjc @inline(__always)
|
||||||
Provides a convenience wrapper for accessing `primitiveValueForKey(...)` with proper calls to `willAccessValueForKey(...)` and `didAccessValueForKey(...)`. This is useful when implementing accessor methods for transient attributes.
|
public func getValue<T>(forKvcKey kvcKey: KeyPath, didGetValue: (Any?) throws -> T) rethrows -> T {
|
||||||
|
|
||||||
- parameter KVCKey: the KVC key
|
self.willAccessValue(forKey: kvcKey)
|
||||||
- parameter didAccessPrimitiveValue: the closure to access the value. This is called between `willAccessValueForKey(...)` and `didAccessValueForKey(...)`
|
defer {
|
||||||
- returns: the primitive value for the KVC key
|
|
||||||
*/
|
self.didAccessValue(forKey: kvcKey)
|
||||||
|
}
|
||||||
|
return try didGetValue(self.primitiveValue(forKey: kvcKey))
|
||||||
|
}
|
||||||
|
|
||||||
|
@nonobjc @inline(__always)
|
||||||
|
public func getValue<T>(forKvcKey kvcKey: KeyPath, willGetValue: () throws -> Void, didGetValue: (Any?) throws -> T) rethrows -> T {
|
||||||
|
|
||||||
|
self.willAccessValue(forKey: kvcKey)
|
||||||
|
defer {
|
||||||
|
|
||||||
|
self.didAccessValue(forKey: kvcKey)
|
||||||
|
}
|
||||||
|
try willGetValue()
|
||||||
|
return try didGetValue(self.primitiveValue(forKey: kvcKey))
|
||||||
|
}
|
||||||
|
|
||||||
|
@nonobjc @inline(__always)
|
||||||
@discardableResult
|
@discardableResult
|
||||||
@nonobjc
|
public func setValue(_ value: Any?, forKvcKey KVCKey: KeyPath) -> Any? {
|
||||||
public func accessValueForKVCKey<T>(_ KVCKey: KeyPath, _ didAccessPrimitiveValue: (Any?) throws -> T) rethrows -> T {
|
|
||||||
|
|
||||||
self.willAccessValue(forKey: KVCKey)
|
|
||||||
defer {
|
|
||||||
|
|
||||||
self.didAccessValue(forKey: KVCKey)
|
|
||||||
}
|
|
||||||
return try didAccessPrimitiveValue(self.primitiveValue(forKey: KVCKey))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Provides a convenience wrapper for setting `setPrimitiveValue(...)` with proper calls to `willChangeValueForKey(...)` and `didChangeValueForKey(...)`. This is useful when implementing mutator methods for transient attributes.
|
|
||||||
|
|
||||||
- parameter value: the value to set the KVC key with
|
|
||||||
- parameter KVCKey: the KVC key
|
|
||||||
*/
|
|
||||||
@nonobjc
|
|
||||||
public func setValue(_ value: Any?, forKVCKey KVCKey: KeyPath) {
|
|
||||||
|
|
||||||
self.willChangeValue(forKey: KVCKey)
|
self.willChangeValue(forKey: KVCKey)
|
||||||
defer {
|
defer {
|
||||||
@@ -128,26 +121,33 @@ public extension NSManagedObject {
|
|||||||
self.didChangeValue(forKey: KVCKey)
|
self.didChangeValue(forKey: KVCKey)
|
||||||
}
|
}
|
||||||
self.setPrimitiveValue(value, forKey: KVCKey)
|
self.setPrimitiveValue(value, forKey: KVCKey)
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@nonobjc @inline(__always)
|
||||||
Provides a convenience wrapper for setting `setPrimitiveValue(...)` with proper calls to `willChangeValueForKey(...)` and `didChangeValueForKey(...)`. This is useful when implementing mutator methods for transient attributes.
|
|
||||||
|
|
||||||
- parameter value: the value to set the KVC key with
|
|
||||||
- parameter KVCKey: the KVC key
|
|
||||||
- parameter didSetPrimitiveValue: the closure called between `willChangeValueForKey(...)` and `didChangeValueForKey(...)`
|
|
||||||
*/
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
@nonobjc
|
public func setValue<T>(_ value: T, forKvcKey KVCKey: KeyPath, willSetValue: (T) throws -> Any?) rethrows -> T {
|
||||||
public func setValue<T>(_ value: Any?, forKVCKey KVCKey: KeyPath, _ didSetPrimitiveValue: (Any?) throws -> T) rethrows -> T {
|
|
||||||
|
|
||||||
self.willChangeValue(forKey: KVCKey)
|
self.willChangeValue(forKey: KVCKey)
|
||||||
defer {
|
defer {
|
||||||
|
|
||||||
self.didChangeValue(forKey: KVCKey)
|
self.didChangeValue(forKey: KVCKey)
|
||||||
}
|
}
|
||||||
self.setPrimitiveValue(value, forKey: KVCKey)
|
self.setPrimitiveValue(try willSetValue(value), forKey: KVCKey)
|
||||||
return try didSetPrimitiveValue(value)
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
@nonobjc @inline(__always)
|
||||||
|
@discardableResult
|
||||||
|
public func setValue<T>(_ value: T, forKvcKey KVCKey: KeyPath, willSetValue: (T) throws -> Any?, didSetValue: (T) -> T = { $0 }) rethrows -> T {
|
||||||
|
|
||||||
|
self.willChangeValue(forKey: KVCKey)
|
||||||
|
defer {
|
||||||
|
|
||||||
|
self.didChangeValue(forKey: KVCKey)
|
||||||
|
}
|
||||||
|
self.setPrimitiveValue(try willSetValue(value), forKey: KVCKey)
|
||||||
|
return didSetValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,4 +167,84 @@ public extension NSManagedObject {
|
|||||||
|
|
||||||
self.managedObjectContext?.refresh(self, mergeChanges: true)
|
self.managedObjectContext?.refresh(self, mergeChanges: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: Deprecated
|
||||||
|
|
||||||
|
/**
|
||||||
|
Provides a convenience wrapper for accessing `primitiveValueForKey(...)` with proper calls to `willAccessValueForKey(...)` and `didAccessValueForKey(...)`. This is useful when implementing accessor methods for transient attributes.
|
||||||
|
|
||||||
|
- parameter KVCKey: the KVC key
|
||||||
|
- returns: the primitive value for the KVC key
|
||||||
|
*/
|
||||||
|
@available(*, deprecated: 3.1, renamed: "getValue(forKvcKey:)")
|
||||||
|
@nonobjc
|
||||||
|
public func accessValueForKVCKey(_ KVCKey: KeyPath) -> Any? {
|
||||||
|
|
||||||
|
self.willAccessValue(forKey: KVCKey)
|
||||||
|
defer {
|
||||||
|
|
||||||
|
self.didAccessValue(forKey: KVCKey)
|
||||||
|
}
|
||||||
|
return self.primitiveValue(forKey: KVCKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Provides a convenience wrapper for accessing `primitiveValueForKey(...)` with proper calls to `willAccessValueForKey(...)` and `didAccessValueForKey(...)`. This is useful when implementing accessor methods for transient attributes.
|
||||||
|
|
||||||
|
- parameter KVCKey: the KVC key
|
||||||
|
- parameter didAccessPrimitiveValue: the closure to access the value. This is called between `willAccessValueForKey(...)` and `didAccessValueForKey(...)`
|
||||||
|
- returns: the primitive value for the KVC key
|
||||||
|
*/
|
||||||
|
@available(*, deprecated: 3.1, renamed: "getValue(forKvcKey:didGetValue:)")
|
||||||
|
@discardableResult
|
||||||
|
@nonobjc
|
||||||
|
public func accessValueForKVCKey<T>(_ KVCKey: KeyPath, _ didAccessPrimitiveValue: (Any?) throws -> T) rethrows -> T {
|
||||||
|
|
||||||
|
self.willAccessValue(forKey: KVCKey)
|
||||||
|
defer {
|
||||||
|
|
||||||
|
self.didAccessValue(forKey: KVCKey)
|
||||||
|
}
|
||||||
|
return try didAccessPrimitiveValue(self.primitiveValue(forKey: KVCKey))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Provides a convenience wrapper for setting `setPrimitiveValue(...)` with proper calls to `willChangeValueForKey(...)` and `didChangeValueForKey(...)`. This is useful when implementing mutator methods for transient attributes.
|
||||||
|
|
||||||
|
- parameter value: the value to set the KVC key with
|
||||||
|
- parameter KVCKey: the KVC key
|
||||||
|
*/
|
||||||
|
@available(*, deprecated: 3.1, renamed: "setValue(_:forKvcKey:)")
|
||||||
|
@nonobjc
|
||||||
|
public func setValue(_ value: Any?, forKVCKey KVCKey: KeyPath) {
|
||||||
|
|
||||||
|
self.willChangeValue(forKey: KVCKey)
|
||||||
|
defer {
|
||||||
|
|
||||||
|
self.didChangeValue(forKey: KVCKey)
|
||||||
|
}
|
||||||
|
self.setPrimitiveValue(value, forKey: KVCKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Provides a convenience wrapper for setting `setPrimitiveValue(...)` with proper calls to `willChangeValueForKey(...)` and `didChangeValueForKey(...)`. This is useful when implementing mutator methods for transient attributes.
|
||||||
|
|
||||||
|
- parameter value: the value to set the KVC key with
|
||||||
|
- parameter KVCKey: the KVC key
|
||||||
|
- parameter didSetPrimitiveValue: the closure called between `willChangeValueForKey(...)` and `didChangeValueForKey(...)`
|
||||||
|
*/
|
||||||
|
@available(*, deprecated: 3.1, renamed: "setValue(_:forKvcKey:didSetValue:)")
|
||||||
|
@discardableResult
|
||||||
|
@nonobjc
|
||||||
|
public func setValue<T>(_ value: Any?, forKVCKey KVCKey: KeyPath, _ didSetPrimitiveValue: (Any?) throws -> T) rethrows -> T {
|
||||||
|
|
||||||
|
self.willChangeValue(forKey: KVCKey)
|
||||||
|
defer {
|
||||||
|
|
||||||
|
self.didChangeValue(forKey: KVCKey)
|
||||||
|
}
|
||||||
|
self.setPrimitiveValue(value, forKey: KVCKey)
|
||||||
|
return try didSetPrimitiveValue(value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,43 +27,48 @@ import CoreData
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
// MARK: - AttributeContainer.Required
|
// MARK: - ValueContainer.Required
|
||||||
|
|
||||||
public extension AttributeContainer.Required where V: CVarArg {
|
public extension ValueContainer.Required {
|
||||||
|
|
||||||
public static func == (_ attribute: AttributeContainer<O>.Required<V>, _ value: V) -> Where {
|
public static func == (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where {
|
||||||
|
|
||||||
return Where(attribute.keyPath, isEqualTo: value)
|
return Where(attribute.keyPath, isEqualTo: value)
|
||||||
}
|
}
|
||||||
public static func < (_ attribute: AttributeContainer<O>.Required<V>, _ value: V) -> Where {
|
public static func < (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where {
|
||||||
|
|
||||||
return Where("%K < %@", attribute.keyPath, value)
|
return Where("%K < %@", attribute.keyPath, value)
|
||||||
}
|
}
|
||||||
public static func > (_ attribute: AttributeContainer<O>.Required<V>, _ value: V) -> Where {
|
public static func > (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where {
|
||||||
|
|
||||||
return Where("%K > %@", attribute.keyPath, value)
|
return Where("%K > %@", attribute.keyPath, value)
|
||||||
}
|
}
|
||||||
public static func <= (_ attribute: AttributeContainer<O>.Required<V>, _ value: V) -> Where {
|
public static func <= (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where {
|
||||||
|
|
||||||
return Where("%K <= %@", attribute.keyPath, value)
|
return Where("%K <= %@", attribute.keyPath, value)
|
||||||
}
|
}
|
||||||
public static func >= (_ attribute: AttributeContainer<O>.Required<V>, _ value: V) -> Where {
|
public static func >= (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where {
|
||||||
|
|
||||||
return Where("%K >= %@", attribute.keyPath, value)
|
return Where("%K >= %@", attribute.keyPath, value)
|
||||||
}
|
}
|
||||||
public static func != (_ attribute: AttributeContainer<O>.Required<V>, _ value: V) -> Where {
|
public static func != (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where {
|
||||||
|
|
||||||
return Where("%K != %@", attribute.keyPath, value)
|
return !Where(attribute.keyPath, isEqualTo: value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: - AttributeContainer.Optional
|
// MARK: - ValueContainer.Optional
|
||||||
|
|
||||||
public extension AttributeContainer.Optional where V: CVarArg {
|
public extension ValueContainer.Optional {
|
||||||
|
|
||||||
public static func == (_ attribute: AttributeContainer<O>.Optional<V>, _ value: V?) -> Where {
|
public static func == (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where {
|
||||||
|
|
||||||
return Where(attribute.keyPath, isEqualTo: value)
|
return Where(attribute.keyPath, isEqualTo: value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static func != (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) -> Where {
|
||||||
|
|
||||||
|
return !Where(attribute.keyPath, isEqualTo: value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- returns: the number of `NSManagedObject`s deleted
|
- returns: the number of `NSManagedObject`s deleted
|
||||||
*/
|
*/
|
||||||
@discardableResult
|
@discardableResult
|
||||||
public func deleteAll<T: NSManagedObject>(_ from: From<T>, _ deleteClauses: DeleteClause...) -> Int? {
|
public func deleteAll<T: DynamicObject>(_ from: From<T>, _ deleteClauses: DeleteClause...) -> Int? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -57,7 +57,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- returns: the number of `NSManagedObject`s deleted
|
- returns: the number of `NSManagedObject`s deleted
|
||||||
*/
|
*/
|
||||||
@discardableResult
|
@discardableResult
|
||||||
public func deleteAll<T: NSManagedObject>(_ from: From<T>, _ deleteClauses: [DeleteClause]) -> Int? {
|
public func deleteAll<T: DynamicObject>(_ from: From<T>, _ deleteClauses: [DeleteClause]) -> Int? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -76,7 +76,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter object: a reference to the object created/fetched outside the transaction
|
- parameter object: a reference to the object created/fetched outside the transaction
|
||||||
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
|
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
|
||||||
*/
|
*/
|
||||||
public func fetchExisting<T: NSManagedObject>(_ object: T) -> T? {
|
public func fetchExisting<T: DynamicObject>(_ object: T) -> T? {
|
||||||
|
|
||||||
return self.context.fetchExisting(object)
|
return self.context.fetchExisting(object)
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter objectID: the `NSManagedObjectID` for the object
|
- parameter objectID: the `NSManagedObjectID` for the object
|
||||||
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
|
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
|
||||||
*/
|
*/
|
||||||
public func fetchExisting<T: NSManagedObject>(_ objectID: NSManagedObjectID) -> T? {
|
public func fetchExisting<T: DynamicObject>(_ objectID: NSManagedObjectID) -> T? {
|
||||||
|
|
||||||
return self.context.fetchExisting(objectID)
|
return self.context.fetchExisting(objectID)
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter objects: an array of `NSManagedObject`s created/fetched outside the transaction
|
- parameter objects: an array of `NSManagedObject`s created/fetched outside the transaction
|
||||||
- returns: the `NSManagedObject` array for objects that exists in the transaction
|
- returns: the `NSManagedObject` array for objects that exists in the transaction
|
||||||
*/
|
*/
|
||||||
public func fetchExisting<T: NSManagedObject, S: Sequence>(_ objects: S) -> [T] where S.Iterator.Element == T {
|
public func fetchExisting<T: DynamicObject, S: Sequence>(_ objects: S) -> [T] where S.Iterator.Element == T {
|
||||||
|
|
||||||
return self.context.fetchExisting(objects)
|
return self.context.fetchExisting(objects)
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter objectIDs: the `NSManagedObjectID` array for the objects
|
- parameter objectIDs: the `NSManagedObjectID` array for the objects
|
||||||
- returns: the `NSManagedObject` array for objects that exists in the transaction
|
- returns: the `NSManagedObject` array for objects that exists in the transaction
|
||||||
*/
|
*/
|
||||||
public func fetchExisting<T: NSManagedObject, S: Sequence>(_ objectIDs: S) -> [T] where S.Iterator.Element == NSManagedObjectID {
|
public func fetchExisting<T: DynamicObject, S: Sequence>(_ objectIDs: S) -> [T] where S.Iterator.Element == NSManagedObjectID {
|
||||||
|
|
||||||
return self.context.fetchExisting(objectIDs)
|
return self.context.fetchExisting(objectIDs)
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchOne<T: ManagedObjectProtocol>(_ from: From<T>, _ fetchClauses: FetchClause...) -> T? {
|
public func fetchOne<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> T? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -137,7 +137,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchOne<T: ManagedObjectProtocol>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> T? {
|
public func fetchOne<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> T? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -153,7 +153,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchAll<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [T]? {
|
public func fetchAll<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [T]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -169,7 +169,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchAll<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [T]? {
|
public func fetchAll<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [T]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -185,7 +185,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchCount<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> Int? {
|
public func fetchCount<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> Int? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -201,7 +201,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchCount<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> Int? {
|
public func fetchCount<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> Int? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -217,7 +217,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchObjectID<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
|
public func fetchObjectID<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -233,7 +233,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchObjectID<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
public func fetchObjectID<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -249,7 +249,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchObjectIDs<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -265,7 +265,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchObjectIDs<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -287,7 +287,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- 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 queryValue<T: NSManagedObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: QueryClause...) -> U? {
|
public func queryValue<T: DynamicObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: QueryClause...) -> U? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -306,7 +306,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- 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 queryValue<T: NSManagedObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U? {
|
public func queryValue<T: DynamicObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -325,7 +325,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- 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...) -> [[String: Any]]? {
|
public func queryAttributes<T: DynamicObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -344,7 +344,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- 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]) -> [[String: Any]]? {
|
public func queryAttributes<T: DynamicObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ import CoreData
|
|||||||
let person = transaction.fetchOne(From<MyPersonEntity>("Configuration1"))
|
let person = transaction.fetchOne(From<MyPersonEntity>("Configuration1"))
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
public struct From<T: ManagedObjectProtocol> {
|
public struct From<T: DynamicObject> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The associated `NSManagedObject` or `ManagedObject` entity class
|
The associated `NSManagedObject` or `CoreStoreObject` entity class
|
||||||
*/
|
*/
|
||||||
public let entityClass: T.Type
|
public let entityClass: T.Type
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public struct From<T: ManagedObjectProtocol> {
|
|||||||
```
|
```
|
||||||
let people = transaction.fetchAll(From<MyPersonEntity>())
|
let people = transaction.fetchAll(From<MyPersonEntity>())
|
||||||
```
|
```
|
||||||
- parameter entity: the associated `NSManagedObject` or `ManagedObject` type
|
- parameter entity: the associated `NSManagedObject` or `CoreStoreObject` type
|
||||||
*/
|
*/
|
||||||
public init(_ entity: T.Type) {
|
public init(_ entity: T.Type) {
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ public struct From<T: ManagedObjectProtocol> {
|
|||||||
```
|
```
|
||||||
let people = transaction.fetchAll(From<MyPersonEntity>(nil, "Configuration1"))
|
let people = transaction.fetchAll(From<MyPersonEntity>(nil, "Configuration1"))
|
||||||
```
|
```
|
||||||
- parameter configuration: the `NSPersistentStore` configuration name to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject` or `ManagedObject`'s entity type. Set to `nil` to use the default configuration.
|
- parameter configuration: the `NSPersistentStore` configuration name to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject` or `CoreStoreObject`'s entity type. Set to `nil` to use the default configuration.
|
||||||
- parameter otherConfigurations: an optional list of other configuration names to associate objects from (see `configuration` parameter)
|
- parameter otherConfigurations: an optional list of other configuration names to associate objects from (see `configuration` parameter)
|
||||||
*/
|
*/
|
||||||
public init(_ configuration: ModelConfiguration, _ otherConfigurations: ModelConfiguration...) {
|
public init(_ configuration: ModelConfiguration, _ otherConfigurations: ModelConfiguration...) {
|
||||||
@@ -93,7 +93,7 @@ public struct From<T: ManagedObjectProtocol> {
|
|||||||
```
|
```
|
||||||
let people = transaction.fetchAll(From<MyPersonEntity>(["Configuration1", "Configuration2"]))
|
let people = transaction.fetchAll(From<MyPersonEntity>(["Configuration1", "Configuration2"]))
|
||||||
```
|
```
|
||||||
- parameter configurations: a list of `NSPersistentStore` configuration names to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject` or `ManagedObject`'s entity type. Set to `nil` to use the default configuration.
|
- parameter configurations: a list of `NSPersistentStore` configuration names to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject` or `CoreStoreObject`'s entity type. Set to `nil` to use the default configuration.
|
||||||
*/
|
*/
|
||||||
public init(_ configurations: [ModelConfiguration]) {
|
public init(_ configurations: [ModelConfiguration]) {
|
||||||
|
|
||||||
@@ -105,8 +105,8 @@ public struct From<T: ManagedObjectProtocol> {
|
|||||||
```
|
```
|
||||||
let people = transaction.fetchAll(From(MyPersonEntity.self, nil, "Configuration1"))
|
let people = transaction.fetchAll(From(MyPersonEntity.self, nil, "Configuration1"))
|
||||||
```
|
```
|
||||||
- parameter entity: the associated `NSManagedObject` or `ManagedObject` type
|
- parameter entity: the associated `NSManagedObject` or `CoreStoreObject` type
|
||||||
- parameter configuration: the `NSPersistentStore` configuration name to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject` or `ManagedObject`'s entity type. Set to `nil` to use the default configuration.
|
- parameter configuration: the `NSPersistentStore` configuration name to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject` or `CoreStoreObject`'s entity type. Set to `nil` to use the default configuration.
|
||||||
- parameter otherConfigurations: an optional list of other configuration names to associate objects from (see `configuration` parameter)
|
- parameter otherConfigurations: an optional list of other configuration names to associate objects from (see `configuration` parameter)
|
||||||
*/
|
*/
|
||||||
public init(_ entity: T.Type, _ configuration: ModelConfiguration, _ otherConfigurations: ModelConfiguration...) {
|
public init(_ entity: T.Type, _ configuration: ModelConfiguration, _ otherConfigurations: ModelConfiguration...) {
|
||||||
@@ -119,8 +119,8 @@ public struct From<T: ManagedObjectProtocol> {
|
|||||||
```
|
```
|
||||||
let people = transaction.fetchAll(From(MyPersonEntity.self, ["Configuration1", "Configuration1"]))
|
let people = transaction.fetchAll(From(MyPersonEntity.self, ["Configuration1", "Configuration1"]))
|
||||||
```
|
```
|
||||||
- parameter entity: the associated `NSManagedObject` or `ManagedObject` type
|
- parameter entity: the associated `NSManagedObject` or `CoreStoreObject` type
|
||||||
- parameter configurations: a list of `NSPersistentStore` configuration names to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject` or `ManagedObject`'s entity type. Set to `nil` to use the default configuration.
|
- parameter configurations: a list of `NSPersistentStore` configuration names to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject` or `CoreStoreObject`'s entity type. Set to `nil` to use the default configuration.
|
||||||
*/
|
*/
|
||||||
public init(_ entity: T.Type, _ configurations: [ModelConfiguration]) {
|
public init(_ entity: T.Type, _ configurations: [ModelConfiguration]) {
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
|||||||
- parameter keyPath: the keyPath to compare with
|
- parameter keyPath: the keyPath to compare with
|
||||||
- parameter object: the arguments for the `==` operator
|
- parameter object: the arguments for the `==` operator
|
||||||
*/
|
*/
|
||||||
public init<T: NSManagedObject>(_ keyPath: KeyPath, isEqualTo object: T?) {
|
public init<T: DynamicObject>(_ keyPath: KeyPath, isEqualTo object: T?) {
|
||||||
|
|
||||||
switch object {
|
switch object {
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
|||||||
self.init(NSPredicate(format: "\(keyPath) == nil"))
|
self.init(NSPredicate(format: "\(keyPath) == nil"))
|
||||||
|
|
||||||
case let object?:
|
case let object?:
|
||||||
self.init(NSPredicate(format: "\(keyPath) == %@", argumentArray: [object.objectID]))
|
self.init(NSPredicate(format: "\(keyPath) == %@", argumentArray: [object.cs_toRaw().objectID]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,9 +169,9 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
|||||||
- parameter keyPath: the keyPath to compare with
|
- parameter keyPath: the keyPath to compare with
|
||||||
- parameter list: the sequence to check membership of
|
- parameter list: the sequence to check membership of
|
||||||
*/
|
*/
|
||||||
public init<S: Sequence>(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element: NSManagedObject {
|
public init<S: Sequence>(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element: DynamicObject {
|
||||||
|
|
||||||
self.init(NSPredicate(format: "\(keyPath) IN %@", list.map({ $0.objectID }) as NSArray))
|
self.init(NSPredicate(format: "\(keyPath) IN %@", list.map({ $0.cs_toRaw().objectID }) as NSArray))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public extension CoreStore {
|
|||||||
- parameter object: a reference to the object created/fetched outside the `DataStack`
|
- parameter object: a reference to the object created/fetched outside the `DataStack`
|
||||||
- returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found.
|
- returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found.
|
||||||
*/
|
*/
|
||||||
public static func fetchExisting<T: NSManagedObject>(_ object: T) -> T? {
|
public static func fetchExisting<T: DynamicObject>(_ object: T) -> T? {
|
||||||
|
|
||||||
return self.defaultStack.fetchExisting(object)
|
return self.defaultStack.fetchExisting(object)
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ public extension CoreStore {
|
|||||||
- parameter objectID: the `NSManagedObjectID` for the object
|
- parameter objectID: the `NSManagedObjectID` for the object
|
||||||
- returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found.
|
- returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found.
|
||||||
*/
|
*/
|
||||||
public static func fetchExisting<T: NSManagedObject>(_ objectID: NSManagedObjectID) -> T? {
|
public static func fetchExisting<T: DynamicObject>(_ objectID: NSManagedObjectID) -> T? {
|
||||||
|
|
||||||
return self.defaultStack.fetchExisting(objectID)
|
return self.defaultStack.fetchExisting(objectID)
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ public extension CoreStore {
|
|||||||
- parameter objects: an array of `NSManagedObject`s created/fetched outside the `DataStack`
|
- parameter objects: an array of `NSManagedObject`s created/fetched outside the `DataStack`
|
||||||
- returns: the `NSManagedObject` array for objects that exists in the `DataStack`
|
- returns: the `NSManagedObject` array for objects that exists in the `DataStack`
|
||||||
*/
|
*/
|
||||||
public static func fetchExisting<T: NSManagedObject, S: Sequence>(_ objects: S) -> [T] where S.Iterator.Element == T {
|
public static func fetchExisting<T: DynamicObject, S: Sequence>(_ objects: S) -> [T] where S.Iterator.Element == T {
|
||||||
|
|
||||||
return self.defaultStack.fetchExisting(objects)
|
return self.defaultStack.fetchExisting(objects)
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ public extension CoreStore {
|
|||||||
- parameter objectIDs: the `NSManagedObjectID` array for the objects
|
- parameter objectIDs: the `NSManagedObjectID` array for the objects
|
||||||
- returns: the `NSManagedObject` array for objects that exists in the `DataStack`
|
- returns: the `NSManagedObject` array for objects that exists in the `DataStack`
|
||||||
*/
|
*/
|
||||||
public static func fetchExisting<T: NSManagedObject, S: Sequence>(_ objectIDs: S) -> [T] where S.Iterator.Element == NSManagedObjectID {
|
public static func fetchExisting<T: DynamicObject, S: Sequence>(_ objectIDs: S) -> [T] where S.Iterator.Element == NSManagedObjectID {
|
||||||
|
|
||||||
return self.defaultStack.fetchExisting(objectIDs)
|
return self.defaultStack.fetchExisting(objectIDs)
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ public extension CoreStore {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public static func fetchOne<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> T? {
|
public static func fetchOne<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> T? {
|
||||||
|
|
||||||
return self.defaultStack.fetchOne(from, fetchClauses)
|
return self.defaultStack.fetchOne(from, fetchClauses)
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ public extension CoreStore {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public static func fetchOne<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> T? {
|
public static func fetchOne<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> T? {
|
||||||
|
|
||||||
return self.defaultStack.fetchOne(from, fetchClauses)
|
return self.defaultStack.fetchOne(from, fetchClauses)
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ public extension CoreStore {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public static func fetchAll<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [T]? {
|
public static func fetchAll<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [T]? {
|
||||||
|
|
||||||
return self.defaultStack.fetchAll(from, fetchClauses)
|
return self.defaultStack.fetchAll(from, fetchClauses)
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ public extension CoreStore {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public static func fetchAll<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [T]? {
|
public static func fetchAll<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [T]? {
|
||||||
|
|
||||||
return self.defaultStack.fetchAll(from, fetchClauses)
|
return self.defaultStack.fetchAll(from, fetchClauses)
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ public extension CoreStore {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public static func fetchCount<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> Int? {
|
public static func fetchCount<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> Int? {
|
||||||
|
|
||||||
return self.defaultStack.fetchCount(from, fetchClauses)
|
return self.defaultStack.fetchCount(from, fetchClauses)
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ public extension CoreStore {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public static func fetchCount<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> Int? {
|
public static func fetchCount<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> Int? {
|
||||||
|
|
||||||
return self.defaultStack.fetchCount(from, fetchClauses)
|
return self.defaultStack.fetchCount(from, fetchClauses)
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ public extension CoreStore {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public static func fetchObjectID<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
|
public static func fetchObjectID<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
|
||||||
|
|
||||||
return self.defaultStack.fetchObjectID(from, fetchClauses)
|
return self.defaultStack.fetchObjectID(from, fetchClauses)
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ public extension CoreStore {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public static func fetchObjectID<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
public static func fetchObjectID<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
||||||
|
|
||||||
return self.defaultStack.fetchObjectID(from, fetchClauses)
|
return self.defaultStack.fetchObjectID(from, fetchClauses)
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ public extension CoreStore {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public static func fetchObjectIDs<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
public static func fetchObjectIDs<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
||||||
|
|
||||||
return self.defaultStack.fetchObjectIDs(from, fetchClauses)
|
return self.defaultStack.fetchObjectIDs(from, fetchClauses)
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ public extension CoreStore {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public static func fetchObjectIDs<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
public static func fetchObjectIDs<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
||||||
|
|
||||||
return self.defaultStack.fetchObjectIDs(from, fetchClauses)
|
return self.defaultStack.fetchObjectIDs(from, fetchClauses)
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ public extension CoreStore {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- 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 queryValue<T: NSManagedObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: QueryClause...) -> U? {
|
public static func queryValue<T: DynamicObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: QueryClause...) -> U? {
|
||||||
|
|
||||||
return self.defaultStack.queryValue(from, selectClause, queryClauses)
|
return self.defaultStack.queryValue(from, selectClause, queryClauses)
|
||||||
}
|
}
|
||||||
@@ -220,7 +220,7 @@ public extension CoreStore {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- 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 queryValue<T: NSManagedObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U? {
|
public static func queryValue<T: DynamicObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U? {
|
||||||
|
|
||||||
return self.defaultStack.queryValue(from, selectClause, queryClauses)
|
return self.defaultStack.queryValue(from, selectClause, queryClauses)
|
||||||
}
|
}
|
||||||
@@ -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.
|
- 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.
|
- 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...) -> [[String: Any]]? {
|
public static func queryAttributes<T: DynamicObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
||||||
|
|
||||||
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
|
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.
|
- 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.
|
- 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]) -> [[String: Any]]? {
|
public static func queryAttributes<T: DynamicObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
||||||
|
|
||||||
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
|
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter object: a reference to the object created/fetched outside the `DataStack`
|
- parameter object: a reference to the object created/fetched outside the `DataStack`
|
||||||
- returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found.
|
- returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found.
|
||||||
*/
|
*/
|
||||||
public func fetchExisting<T: NSManagedObject>(_ object: T) -> T? {
|
public func fetchExisting<T: DynamicObject>(_ object: T) -> T? {
|
||||||
|
|
||||||
return self.mainContext.fetchExisting(object)
|
return self.mainContext.fetchExisting(object)
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter objectID: the `NSManagedObjectID` for the object
|
- parameter objectID: the `NSManagedObjectID` for the object
|
||||||
- returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found.
|
- returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found.
|
||||||
*/
|
*/
|
||||||
public func fetchExisting<T: NSManagedObject>(_ objectID: NSManagedObjectID) -> T? {
|
public func fetchExisting<T: DynamicObject>(_ objectID: NSManagedObjectID) -> T? {
|
||||||
|
|
||||||
return self.mainContext.fetchExisting(objectID)
|
return self.mainContext.fetchExisting(objectID)
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter objects: an array of `NSManagedObject`s created/fetched outside the `DataStack`
|
- parameter objects: an array of `NSManagedObject`s created/fetched outside the `DataStack`
|
||||||
- returns: the `NSManagedObject` array for objects that exists in the `DataStack`
|
- returns: the `NSManagedObject` array for objects that exists in the `DataStack`
|
||||||
*/
|
*/
|
||||||
public func fetchExisting<T: NSManagedObject, S: Sequence>(_ objects: S) -> [T] where S.Iterator.Element == T {
|
public func fetchExisting<T: DynamicObject, S: Sequence>(_ objects: S) -> [T] where S.Iterator.Element == T {
|
||||||
|
|
||||||
return self.mainContext.fetchExisting(objects)
|
return self.mainContext.fetchExisting(objects)
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter objectIDs: the `NSManagedObjectID` array for the objects
|
- parameter objectIDs: the `NSManagedObjectID` array for the objects
|
||||||
- returns: the `NSManagedObject` array for objects that exists in the `DataStack`
|
- returns: the `NSManagedObject` array for objects that exists in the `DataStack`
|
||||||
*/
|
*/
|
||||||
public func fetchExisting<T: NSManagedObject, S: Sequence>(_ objectIDs: S) -> [T] where S.Iterator.Element == NSManagedObjectID {
|
public func fetchExisting<T: DynamicObject, S: Sequence>(_ objectIDs: S) -> [T] where S.Iterator.Element == NSManagedObjectID {
|
||||||
|
|
||||||
return self.mainContext.fetchExisting(objectIDs)
|
return self.mainContext.fetchExisting(objectIDs)
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchOne<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> T? {
|
public func fetchOne<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> T? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -100,7 +100,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchOne<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> T? {
|
public func fetchOne<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> T? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -116,7 +116,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchAll<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [T]? {
|
public func fetchAll<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [T]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -132,7 +132,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchAll<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [T]? {
|
public func fetchAll<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [T]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -148,7 +148,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchCount<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> Int? {
|
public func fetchCount<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> Int? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -164,7 +164,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchCount<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> Int? {
|
public func fetchCount<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> Int? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -180,7 +180,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchObjectID<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
|
public func fetchObjectID<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -196,7 +196,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchObjectID<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
public func fetchObjectID<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -212,7 +212,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchObjectIDs<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -228,7 +228,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
public func fetchObjectIDs<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -250,7 +250,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- 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 queryValue<T: NSManagedObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: QueryClause...) -> U? {
|
public func queryValue<T: DynamicObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: QueryClause...) -> U? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -269,7 +269,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- 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 queryValue<T: NSManagedObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U? {
|
public func queryValue<T: DynamicObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -288,7 +288,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- 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...) -> [[String: Any]]? {
|
public func queryAttributes<T: DynamicObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
@@ -307,7 +307,7 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- 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]) -> [[String: Any]]? {
|
public func queryAttributes<T: DynamicObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
Thread.isMainThread,
|
Thread.isMainThread,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter object: a reference to the object created/fetched outside the `FetchableSource`'s context
|
- parameter object: a reference to the object created/fetched outside the `FetchableSource`'s context
|
||||||
- returns: the `NSManagedObject` instance if the object exists in the `FetchableSource`'s context, or `nil` if not found.
|
- returns: the `NSManagedObject` instance if the object exists in the `FetchableSource`'s context, or `nil` if not found.
|
||||||
*/
|
*/
|
||||||
func fetchExisting<T: NSManagedObject>(_ object: T) -> T?
|
func fetchExisting<T: DynamicObject>(_ object: T) -> T?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObject` instance in the `FetchableSource`'s context from an `NSManagedObjectID`.
|
Fetches the `NSManagedObject` instance in the `FetchableSource`'s context from an `NSManagedObjectID`.
|
||||||
@@ -48,7 +48,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter objectID: the `NSManagedObjectID` for the object
|
- parameter objectID: the `NSManagedObjectID` for the object
|
||||||
- returns: the `NSManagedObject` instance if the object exists in the `FetchableSource`, or `nil` if not found.
|
- returns: the `NSManagedObject` instance if the object exists in the `FetchableSource`, or `nil` if not found.
|
||||||
*/
|
*/
|
||||||
func fetchExisting<T: NSManagedObject>(_ objectID: NSManagedObjectID) -> T?
|
func fetchExisting<T: DynamicObject>(_ objectID: NSManagedObjectID) -> T?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObject` instances in the `FetchableSource`'s context from references created from another managed object context.
|
Fetches the `NSManagedObject` instances in the `FetchableSource`'s context from references created from another managed object context.
|
||||||
@@ -56,7 +56,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter objects: an array of `NSManagedObject`s created/fetched outside the `FetchableSource`'s context
|
- parameter objects: an array of `NSManagedObject`s created/fetched outside the `FetchableSource`'s context
|
||||||
- returns: the `NSManagedObject` array for objects that exists in the `FetchableSource`
|
- returns: the `NSManagedObject` array for objects that exists in the `FetchableSource`
|
||||||
*/
|
*/
|
||||||
func fetchExisting<T: NSManagedObject, S: Sequence>(_ objects: S) -> [T] where S.Iterator.Element == T
|
func fetchExisting<T: DynamicObject, S: Sequence>(_ objects: S) -> [T] where S.Iterator.Element == T
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObject` instances in the `FetchableSource`'s context from a list of `NSManagedObjectID`.
|
Fetches the `NSManagedObject` instances in the `FetchableSource`'s context from a list of `NSManagedObjectID`.
|
||||||
@@ -64,7 +64,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter objectIDs: the `NSManagedObjectID` array for the objects
|
- parameter objectIDs: the `NSManagedObjectID` array for the objects
|
||||||
- returns: the `NSManagedObject` array for objects that exists in the `FetchableSource`'s context
|
- returns: the `NSManagedObject` array for objects that exists in the `FetchableSource`'s context
|
||||||
*/
|
*/
|
||||||
func fetchExisting<T: NSManagedObject, S: Sequence>(_ objectIDs: S) -> [T] where S.Iterator.Element == NSManagedObjectID
|
func fetchExisting<T: DynamicObject, S: Sequence>(_ objectIDs: S) -> [T] where S.Iterator.Element == NSManagedObjectID
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the first `NSManagedObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the first `NSManagedObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
@@ -73,7 +73,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
func fetchOne<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> T?
|
func fetchOne<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> T?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the first `NSManagedObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the first `NSManagedObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
@@ -82,7 +82,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
func fetchOne<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> T?
|
func fetchOne<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> T?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches all `NSManagedObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches all `NSManagedObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
@@ -91,7 +91,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
func fetchAll<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [T]?
|
func fetchAll<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [T]?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches all `NSManagedObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches all `NSManagedObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
@@ -100,7 +100,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
func fetchAll<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [T]?
|
func fetchAll<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [T]?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the number of `NSManagedObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the number of `NSManagedObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
@@ -109,7 +109,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
func fetchCount<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> Int?
|
func fetchCount<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> Int?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the number of `NSManagedObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the number of `NSManagedObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
@@ -118,7 +118,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
func fetchCount<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> Int?
|
func fetchCount<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> Int?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
@@ -127,7 +127,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
func fetchObjectID<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> NSManagedObjectID?
|
func fetchObjectID<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> NSManagedObjectID?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
@@ -136,7 +136,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
func fetchObjectID<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID?
|
func fetchObjectID<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
@@ -145,7 +145,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
func fetchObjectIDs<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]?
|
func fetchObjectIDs<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
@@ -154,7 +154,7 @@ public protocol FetchableSource: class {
|
|||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s
|
||||||
*/
|
*/
|
||||||
func fetchObjectIDs<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]?
|
func fetchObjectIDs<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The internal `NSManagedObjectContext` managed by this `FetchableSource`. Using this context directly should typically be avoided, and is provided by CoreStore only for extremely specialized cases.
|
The internal `NSManagedObjectContext` managed by this `FetchableSource`. Using this context directly should typically be avoided, and is provided by CoreStore only for extremely specialized cases.
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public protocol QueryableSource: class {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
*/
|
*/
|
||||||
func queryValue<T: NSManagedObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: QueryClause...) -> U?
|
func queryValue<T: DynamicObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: QueryClause...) -> U?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
Queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
@@ -56,7 +56,7 @@ public protocol QueryableSource: class {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
*/
|
*/
|
||||||
func queryValue<T: NSManagedObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U?
|
func queryValue<T: DynamicObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
Queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
@@ -68,7 +68,7 @@ public protocol QueryableSource: class {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
*/
|
*/
|
||||||
func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]?
|
func queryAttributes<T: DynamicObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
Queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
@@ -80,7 +80,7 @@ public protocol QueryableSource: class {
|
|||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
*/
|
*/
|
||||||
func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]?
|
func queryAttributes<T: DynamicObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The internal `NSManagedObjectContext` managed by this `QueryableSource`. Using this context directly should typically be avoided, and is provided by CoreStore only for extremely specialized cases.
|
The internal `NSManagedObjectContext` managed by this `QueryableSource`. Using this context directly should typically be avoided, and is provided by CoreStore only for extremely specialized cases.
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public extension BaseDataTransaction {
|
|||||||
*/
|
*/
|
||||||
public func importObject<T>(
|
public func importObject<T>(
|
||||||
_ into: Into<T>,
|
_ into: Into<T>,
|
||||||
source: T.ImportSource) throws -> T? where T: NSManagedObject, T: ImportableObject {
|
source: T.ImportSource) throws -> T? where T: DynamicObject, T: ImportableObject {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -71,7 +71,7 @@ public extension BaseDataTransaction {
|
|||||||
*/
|
*/
|
||||||
public func importObject<T>(
|
public func importObject<T>(
|
||||||
_ object: T,
|
_ object: T,
|
||||||
source: T.ImportSource) throws where T: NSManagedObject, T: ImportableObject {
|
source: T.ImportSource) throws where T: DynamicObject, T: ImportableObject {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -99,7 +99,7 @@ public extension BaseDataTransaction {
|
|||||||
*/
|
*/
|
||||||
public func importObjects<T, S: Sequence>(
|
public func importObjects<T, S: Sequence>(
|
||||||
_ into: Into<T>,
|
_ into: Into<T>,
|
||||||
sourceArray: S) throws -> [T] where T: NSManagedObject, T: ImportableObject, S.Iterator.Element == T.ImportSource {
|
sourceArray: S) throws -> [T] where T: DynamicObject, T: ImportableObject, S.Iterator.Element == T.ImportSource {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -135,7 +135,7 @@ public extension BaseDataTransaction {
|
|||||||
*/
|
*/
|
||||||
public func importUniqueObject<T>(
|
public func importUniqueObject<T>(
|
||||||
_ into: Into<T>,
|
_ into: Into<T>,
|
||||||
source: T.ImportSource) throws -> T? where T: NSManagedObject, T: ImportableUniqueObject {
|
source: T.ImportSource) throws -> T? where T: DynamicObject, T: ImportableUniqueObject {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -188,7 +188,7 @@ public extension BaseDataTransaction {
|
|||||||
public func importUniqueObjects<T, S: Sequence>(
|
public func importUniqueObjects<T, S: Sequence>(
|
||||||
_ into: Into<T>,
|
_ into: Into<T>,
|
||||||
sourceArray: S,
|
sourceArray: S,
|
||||||
preProcess: @escaping (_ mapping: [T.UniqueIDType: T.ImportSource]) throws -> [T.UniqueIDType: T.ImportSource] = { $0 }) throws -> [T] where T: NSManagedObject, T: ImportableUniqueObject, S.Iterator.Element == T.ImportSource {
|
preProcess: @escaping (_ mapping: [T.UniqueIDType: T.ImportSource]) throws -> [T.UniqueIDType: T.ImportSource] = { $0 }) throws -> [T] where T: DynamicObject, T: ImportableUniqueObject, S.Iterator.Element == T.ImportSource {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ import CoreData
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
public protocol ImportableObject: class, NSObjectProtocol, AnyObject {
|
public protocol ImportableObject: class {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The data type for the import source. This is most commonly an `NSDictionary` or another external source such as an `NSUserDefaults`.
|
The data type for the import source. This is most commonly an `NSDictionary` or another external source such as an `NSUserDefaults`.
|
||||||
@@ -71,15 +71,6 @@ public protocol ImportableObject: class, NSObjectProtocol, AnyObject {
|
|||||||
- parameter transaction: the transaction that invoked the import. Use the transaction to fetch or create related objects if needed.
|
- parameter transaction: the transaction that invoked the import. Use the transaction to fetch or create related objects if needed.
|
||||||
*/
|
*/
|
||||||
func didInsert(from source: ImportSource, in transaction: BaseDataTransaction) throws
|
func didInsert(from source: ImportSource, in transaction: BaseDataTransaction) throws
|
||||||
|
|
||||||
|
|
||||||
// MARK: Obsolete (`deprecated` only for reference, please use new methods)
|
|
||||||
|
|
||||||
@available(*, deprecated: 3.0.0, renamed: "shouldInsert(from:in:)")
|
|
||||||
static func shouldInsertFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) -> Bool
|
|
||||||
|
|
||||||
@available(*, deprecated: 3.0.0, renamed: "didInsert(from:in:)")
|
|
||||||
func didInsertFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) throws
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -114,24 +114,6 @@ public protocol ImportableUniqueObject: ImportableObject {
|
|||||||
- parameter transaction: the transaction that invoked the import. Use the transaction to fetch or create related objects if needed.
|
- parameter transaction: the transaction that invoked the import. Use the transaction to fetch or create related objects if needed.
|
||||||
*/
|
*/
|
||||||
func update(from source: ImportSource, in transaction: BaseDataTransaction) throws
|
func update(from source: ImportSource, in transaction: BaseDataTransaction) throws
|
||||||
|
|
||||||
|
|
||||||
// MARK: Obsolete (`deprecated` only for reference, please use new methods)
|
|
||||||
|
|
||||||
@available(*, deprecated: 3.0.0, renamed: "shouldInsert(from:in:)")
|
|
||||||
static func shouldInsertFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) -> Bool
|
|
||||||
|
|
||||||
@available(*, deprecated: 3.0.0, renamed: "shouldUpdate(from:in:)")
|
|
||||||
static func shouldUpdateFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) -> Bool
|
|
||||||
|
|
||||||
@available(*, deprecated: 3.0.0, renamed: "uniqueID(from:in:)")
|
|
||||||
static func uniqueIDFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) throws -> UniqueIDType?
|
|
||||||
|
|
||||||
@available(*, deprecated: 3.0.0, renamed: "didInsert(from:in:)")
|
|
||||||
func didInsertFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) throws
|
|
||||||
|
|
||||||
@available(*, deprecated: 3.0.0, renamed: "update(from:in:)")
|
|
||||||
func updateFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) throws
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -191,22 +173,25 @@ public extension ImportableUniqueObject {
|
|||||||
|
|
||||||
// MARK: - ImportableUniqueObject (Default Implementations)
|
// MARK: - ImportableUniqueObject (Default Implementations)
|
||||||
|
|
||||||
public extension ImportableUniqueObject where Self: NSManagedObject {
|
public extension ImportableUniqueObject where Self: DynamicObject {
|
||||||
|
|
||||||
var uniqueIDValue: UniqueIDType {
|
var uniqueIDValue: UniqueIDType {
|
||||||
|
|
||||||
get {
|
get {
|
||||||
|
|
||||||
return UniqueIDType.cs_fromImportableNativeType(
|
return self.cs_toRaw().getValue(
|
||||||
self.value(forKey: type(of: self).uniqueIDKeyPath) as! UniqueIDType.ImportableNativeType
|
forKvcKey: type(of: self).uniqueIDKeyPath,
|
||||||
)!
|
didGetValue: { UniqueIDType.cs_fromImportableNativeType($0 as! UniqueIDType.ImportableNativeType)! }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
|
||||||
self.setValue(
|
self.cs_toRaw()
|
||||||
newValue.cs_toImportableNativeType(),
|
.setValue(
|
||||||
forKey: type(of: self).uniqueIDKeyPath
|
newValue,
|
||||||
)
|
forKvcKey: type(of: self).uniqueIDKeyPath,
|
||||||
|
willSetValue: { $0.cs_toImportableNativeType() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,16 +27,15 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - CoreStoreFetchedResultsController
|
// MARK: - CoreStoreFetchedResultsController
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
internal final class CoreStoreFetchedResultsController: NSFetchedResultsController<NSManagedObject> {
|
internal final class CoreStoreFetchedResultsController: NSFetchedResultsController<NSManagedObject> {
|
||||||
|
|
||||||
// MARK: Internal
|
// MARK: Internal
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal convenience init<T: NSManagedObject>(dataStack: DataStack, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
internal convenience init<T: DynamicObject>(dataStack: DataStack, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>?, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
||||||
|
|
||||||
self.init(
|
self.init(
|
||||||
context: dataStack.mainContext,
|
context: dataStack.mainContext,
|
||||||
@@ -48,7 +47,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
|
|||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal init<T: NSManagedObject>(context: NSManagedObjectContext, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
internal init<T: DynamicObject>(context: NSManagedObjectContext, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>?, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
|
||||||
|
|
||||||
_ = from?.applyToFetchRequest(
|
_ = from?.applyToFetchRequest(
|
||||||
fetchRequest,
|
fetchRequest,
|
||||||
@@ -115,5 +114,3 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
|
|||||||
@nonobjc
|
@nonobjc
|
||||||
private let reapplyAffectedStores: (_ fetchRequest: NSFetchRequest<NSManagedObject>, _ context: NSManagedObjectContext) -> Bool
|
private let reapplyAffectedStores: (_ fetchRequest: NSFetchRequest<NSManagedObject>, _ context: NSManagedObjectContext) -> Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - FetchedResultsControllerHandler
|
// MARK: - FetchedResultsControllerHandler
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
internal protocol FetchedResultsControllerHandler: class {
|
internal protocol FetchedResultsControllerHandler: class {
|
||||||
|
|
||||||
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: Any, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?)
|
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: Any, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?)
|
||||||
@@ -47,7 +46,8 @@ internal protocol FetchedResultsControllerHandler: class {
|
|||||||
|
|
||||||
// MARK: - FetchedResultsControllerDelegate
|
// MARK: - FetchedResultsControllerDelegate
|
||||||
|
|
||||||
internal final class FetchedResultsControllerDelegate<EntityType: NSManagedObject>: NSObject, NSFetchedResultsControllerDelegate {
|
@available(OSX 10.12, *)
|
||||||
|
internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResultsControllerDelegate {
|
||||||
|
|
||||||
// MARK: Internal
|
// MARK: Internal
|
||||||
|
|
||||||
@@ -240,5 +240,3 @@ internal final class FetchedResultsControllerDelegate<EntityType: NSManagedObjec
|
|||||||
@nonobjc
|
@nonobjc
|
||||||
private var insertedSections = Set<Int>()
|
private var insertedSections = Set<Int>()
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -34,15 +34,16 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
// MARK: FetchableSource
|
// MARK: FetchableSource
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchExisting<T: NSManagedObject>(_ object: T) -> T? {
|
public func fetchExisting<T: DynamicObject>(_ object: T) -> T? {
|
||||||
|
|
||||||
if object.objectID.isTemporaryID {
|
let rawObject = object.cs_toRaw()
|
||||||
|
if rawObject.objectID.isTemporaryID {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
try withExtendedLifetime(self) { (context: NSManagedObjectContext) -> Void in
|
try withExtendedLifetime(self) { (context: NSManagedObjectContext) -> Void in
|
||||||
|
|
||||||
try context.obtainPermanentIDs(for: [object])
|
try context.obtainPermanentIDs(for: [rawObject])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
@@ -56,8 +57,12 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
|
|
||||||
let existingObject = try self.existingObject(with: object.objectID)
|
let existingRawObject = try self.existingObject(with: rawObject.objectID)
|
||||||
return (existingObject as! T)
|
if existingRawObject === rawObject {
|
||||||
|
|
||||||
|
return object
|
||||||
|
}
|
||||||
|
return T.cs_fromRaw(object: existingRawObject)
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
|
||||||
@@ -70,11 +75,12 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchExisting<T: NSManagedObject>(_ objectID: NSManagedObjectID) -> T? {
|
public func fetchExisting<T: DynamicObject>(_ objectID: NSManagedObjectID) -> T? {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
return (try self.existingObject(with: objectID) as! T)
|
let existingObject = try self.existingObject(with: objectID)
|
||||||
|
return T.cs_fromRaw(object: existingObject)
|
||||||
}
|
}
|
||||||
catch _ {
|
catch _ {
|
||||||
|
|
||||||
@@ -83,25 +89,25 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchExisting<T: NSManagedObject, S: Sequence>(_ objects: S) -> [T] where S.Iterator.Element == T {
|
public func fetchExisting<T: DynamicObject, S: Sequence>(_ objects: S) -> [T] where S.Iterator.Element == T {
|
||||||
|
|
||||||
return objects.flatMap { (try? self.existingObject(with: $0.objectID)) as? T }
|
return objects.flatMap({ self.fetchExisting($0.cs_toRaw().objectID) })
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchExisting<T: NSManagedObject, S: Sequence>(_ objectIDs: S) -> [T] where S.Iterator.Element == NSManagedObjectID {
|
public func fetchExisting<T: DynamicObject, S: Sequence>(_ objectIDs: S) -> [T] where S.Iterator.Element == NSManagedObjectID {
|
||||||
|
|
||||||
return objectIDs.flatMap { (try? self.existingObject(with: $0)) as? T }
|
return objectIDs.flatMap({ self.fetchExisting($0) })
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchOne<T: ManagedObjectProtocol>(_ from: From<T>, _ fetchClauses: FetchClause...) -> T? {
|
public func fetchOne<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> T? {
|
||||||
|
|
||||||
return self.fetchOne(from, fetchClauses)
|
return self.fetchOne(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchOne<T: ManagedObjectProtocol>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> T? {
|
public func fetchOne<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> T? {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
@@ -114,18 +120,17 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return self.fetchOne(fetchRequest.dynamicCast())
|
return self.fetchOne(fetchRequest.dynamicCast()).flatMap(from.entityClass.cs_fromRaw)
|
||||||
.flatMap(from.entityClass.cs_from)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchAll<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [T]? {
|
public func fetchAll<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [T]? {
|
||||||
|
|
||||||
return self.fetchAll(from, fetchClauses)
|
return self.fetchAll(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchAll<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [T]? {
|
public func fetchAll<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [T]? {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
@@ -138,17 +143,18 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return self.fetchAll(fetchRequest.dynamicCast())
|
let entityClass = from.entityClass
|
||||||
|
return self.fetchAll(fetchRequest.dynamicCast())?.map(entityClass.cs_fromRaw)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchCount<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> Int? {
|
public func fetchCount<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> Int? {
|
||||||
|
|
||||||
return self.fetchCount(from, fetchClauses)
|
return self.fetchCount(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchCount<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> Int? {
|
public func fetchCount<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> Int? {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
@@ -162,13 +168,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchObjectID<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
|
public func fetchObjectID<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
|
||||||
|
|
||||||
return self.fetchObjectID(from, fetchClauses)
|
return self.fetchObjectID(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchObjectID<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
public func fetchObjectID<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
@@ -185,13 +191,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchObjectIDs<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<T: DynamicObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
||||||
|
|
||||||
return self.fetchObjectIDs(from, fetchClauses)
|
return self.fetchObjectIDs(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchObjectIDs<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<T: DynamicObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
@@ -238,13 +244,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
// MARK: QueryableSource
|
// MARK: QueryableSource
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func queryValue<T: NSManagedObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: QueryClause...) -> U? {
|
public func queryValue<T: DynamicObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: QueryClause...) -> U? {
|
||||||
|
|
||||||
return self.queryValue(from, selectClause, queryClauses)
|
return self.queryValue(from, selectClause, queryClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func queryValue<T: NSManagedObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U? {
|
public func queryValue<T: DynamicObject, U: QueryableAttributeType>(_ from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U? {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
@@ -263,13 +269,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
public func queryAttributes<T: DynamicObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
||||||
|
|
||||||
return self.queryAttributes(from, selectClause, queryClauses)
|
return self.queryAttributes(from, selectClause, queryClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
public func queryAttributes<T: DynamicObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
@@ -296,6 +302,34 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: Deleting
|
||||||
|
|
||||||
|
@nonobjc
|
||||||
|
internal func deleteAll<T: DynamicObject>(_ from: From<T>, _ deleteClauses: DeleteClause...) -> Int? {
|
||||||
|
|
||||||
|
return self.deleteAll(from, deleteClauses)
|
||||||
|
}
|
||||||
|
|
||||||
|
@nonobjc
|
||||||
|
internal func deleteAll<T: DynamicObject>(_ from: From<T>, _ deleteClauses: [DeleteClause]) -> Int? {
|
||||||
|
|
||||||
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
|
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
|
|
||||||
|
fetchRequest.fetchLimit = 0
|
||||||
|
fetchRequest.resultType = .managedObjectResultType
|
||||||
|
fetchRequest.returnsObjectsAsFaults = true
|
||||||
|
fetchRequest.includesPropertyValues = false
|
||||||
|
deleteClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||||
|
|
||||||
|
guard storeFound else {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return self.deleteAll(fetchRequest.dynamicCast())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: Deprecated
|
// MARK: Deprecated
|
||||||
|
|
||||||
@available(*, deprecated, renamed: "unsafeContext()")
|
@available(*, deprecated, renamed: "unsafeContext()")
|
||||||
@@ -520,31 +554,6 @@ internal extension NSManagedObjectContext {
|
|||||||
|
|
||||||
// MARK: Deleting
|
// MARK: Deleting
|
||||||
|
|
||||||
@nonobjc
|
|
||||||
internal func deleteAll<T: NSManagedObject>(_ from: From<T>, _ deleteClauses: DeleteClause...) -> Int? {
|
|
||||||
|
|
||||||
return self.deleteAll(from, deleteClauses)
|
|
||||||
}
|
|
||||||
|
|
||||||
@nonobjc
|
|
||||||
internal func deleteAll<T: NSManagedObject>(_ from: From<T>, _ deleteClauses: [DeleteClause]) -> Int? {
|
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
|
||||||
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
|
||||||
|
|
||||||
fetchRequest.fetchLimit = 0
|
|
||||||
fetchRequest.resultType = .managedObjectResultType
|
|
||||||
fetchRequest.returnsObjectsAsFaults = true
|
|
||||||
fetchRequest.includesPropertyValues = false
|
|
||||||
deleteClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
|
||||||
|
|
||||||
guard storeFound else {
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return self.deleteAll(fetchRequest.dynamicCast())
|
|
||||||
}
|
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal func deleteAll<T: NSManagedObject>(_ fetchRequest: NSFetchRequest<T>) -> Int? {
|
internal func deleteAll<T: NSManagedObject>(_ fetchRequest: NSFetchRequest<T>) -> Int? {
|
||||||
|
|
||||||
|
|||||||
@@ -350,10 +350,9 @@ extension LegacySQLiteStore: CustomDebugStringConvertible, CoreStoreDebugStringC
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - ListMonitor
|
// MARK: - ListMonitor
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
private struct CoreStoreFetchedSectionInfoWrapper: CoreStoreDebugStringConvertible {
|
private struct CoreStoreFetchedSectionInfoWrapper: CoreStoreDebugStringConvertible {
|
||||||
|
|
||||||
let sectionInfo: NSFetchedResultsSectionInfo
|
let sectionInfo: NSFetchedResultsSectionInfo
|
||||||
@@ -368,6 +367,7 @@ private struct CoreStoreFetchedSectionInfoWrapper: CoreStoreDebugStringConvertib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
extension ListMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
|
extension ListMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
|
||||||
|
|
||||||
// MARK: CustomDebugStringConvertible
|
// MARK: CustomDebugStringConvertible
|
||||||
@@ -390,7 +390,6 @@ extension ListMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvert
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// MARK: - LocalStorageOptions
|
// MARK: - LocalStorageOptions
|
||||||
@@ -560,10 +559,9 @@ extension MigrationType: CustomDebugStringConvertible, CoreStoreDebugStringConve
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - ObjectMonitor
|
// MARK: - ObjectMonitor
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
extension ObjectMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
|
extension ObjectMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
|
||||||
|
|
||||||
// MARK: CustomDebugStringConvertible
|
// MARK: CustomDebugStringConvertible
|
||||||
@@ -585,7 +583,7 @@ extension ObjectMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConve
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// MARK: - OrderBy
|
// MARK: - OrderBy
|
||||||
|
|
||||||
@@ -646,10 +644,9 @@ extension SaveResult: CustomDebugStringConvertible, CoreStoreDebugStringConverti
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - SectionBy
|
// MARK: - SectionBy
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
extension SectionBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
|
extension SectionBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
|
||||||
|
|
||||||
// MARK: CustomDebugStringConvertible
|
// MARK: CustomDebugStringConvertible
|
||||||
@@ -670,7 +667,6 @@ extension SectionBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertib
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// MARK: - Select
|
// MARK: - Select
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public extension CSBaseDataTransaction {
|
|||||||
@objc
|
@objc
|
||||||
public func fetchExistingObject(_ object: NSManagedObject) -> Any? {
|
public func fetchExistingObject(_ object: NSManagedObject) -> Any? {
|
||||||
|
|
||||||
return self.bridgeToSwift.context.fetchExisting(object)
|
return self.bridgeToSwift.context.fetchExisting(object) as NSManagedObject?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +52,7 @@ public extension CSBaseDataTransaction {
|
|||||||
@objc
|
@objc
|
||||||
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
|
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
|
||||||
|
|
||||||
return self.bridgeToSwift.context.fetchExisting(objectID)
|
return self.bridgeToSwift.context.fetchExisting(objectID) as NSManagedObject?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,7 +64,7 @@ public extension CSBaseDataTransaction {
|
|||||||
@objc
|
@objc
|
||||||
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
|
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
|
||||||
|
|
||||||
return self.bridgeToSwift.context.fetchExisting(objects)
|
return self.bridgeToSwift.context.fetchExisting(objects) as [NSManagedObject]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +76,7 @@ public extension CSBaseDataTransaction {
|
|||||||
@objc
|
@objc
|
||||||
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
|
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
|
||||||
|
|
||||||
return self.bridgeToSwift.context.fetchExisting(objectIDs)
|
return self.bridgeToSwift.context.fetchExisting(objectIDs) as [NSManagedObject]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - CSCoreStore
|
// MARK: - CSCoreStore
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension CSCoreStore {
|
public extension CSCoreStore {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,5 +111,3 @@ public extension CSCoreStore {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - CSDataStack
|
// MARK: - CSDataStack
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension CSDataStack {
|
public extension CSDataStack {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,10 +41,7 @@ public extension CSDataStack {
|
|||||||
@objc
|
@objc
|
||||||
public func monitorObject(_ object: NSManagedObject) -> CSObjectMonitor {
|
public func monitorObject(_ object: NSManagedObject) -> CSObjectMonitor {
|
||||||
|
|
||||||
return bridge {
|
return self.bridgeToSwift.monitorObject(object).bridgeToObjectiveC
|
||||||
|
|
||||||
self.bridgeToSwift.monitorObject(object)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,18 +62,15 @@ public extension CSDataStack {
|
|||||||
fetchClauses.contains { $0 is CSOrderBy },
|
fetchClauses.contains { $0 is CSOrderBy },
|
||||||
"A CSListMonitor requires a CSOrderBy clause."
|
"A CSListMonitor requires a CSOrderBy clause."
|
||||||
)
|
)
|
||||||
return bridge {
|
return ListMonitor(
|
||||||
|
dataStack: self.bridgeToSwift,
|
||||||
|
from: from.bridgeToSwift,
|
||||||
|
sectionBy: nil,
|
||||||
|
applyFetchClauses: { (fetchRequest) in
|
||||||
|
|
||||||
ListMonitor(
|
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest as! NSFetchRequest<NSFetchRequestResult>) }
|
||||||
dataStack: self.bridgeToSwift,
|
}
|
||||||
from: from.bridgeToSwift,
|
).bridgeToObjectiveC
|
||||||
sectionBy: nil,
|
|
||||||
applyFetchClauses: { (fetchRequest) in
|
|
||||||
|
|
||||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest as! NSFetchRequest<NSFetchRequestResult>) }
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,18 +125,15 @@ public extension CSDataStack {
|
|||||||
fetchClauses.contains { $0 is CSOrderBy },
|
fetchClauses.contains { $0 is CSOrderBy },
|
||||||
"A CSListMonitor requires an CSOrderBy clause."
|
"A CSListMonitor requires an CSOrderBy clause."
|
||||||
)
|
)
|
||||||
return bridge {
|
return ListMonitor(
|
||||||
|
dataStack: self.bridgeToSwift,
|
||||||
|
from: from.bridgeToSwift,
|
||||||
|
sectionBy: sectionBy.bridgeToSwift,
|
||||||
|
applyFetchClauses: { (fetchRequest) in
|
||||||
|
|
||||||
ListMonitor(
|
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest as! NSFetchRequest<NSFetchRequestResult>) }
|
||||||
dataStack: self.bridgeToSwift,
|
}
|
||||||
from: from.bridgeToSwift,
|
).bridgeToObjectiveC
|
||||||
sectionBy: sectionBy.bridgeToSwift,
|
|
||||||
applyFetchClauses: { (fetchRequest) in
|
|
||||||
|
|
||||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest as! NSFetchRequest<NSFetchRequestResult>) }
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,5 +169,3 @@ public extension CSDataStack {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public extension CSDataStack {
|
|||||||
@objc
|
@objc
|
||||||
public func fetchExistingObject(_ object: NSManagedObject) -> Any? {
|
public func fetchExistingObject(_ object: NSManagedObject) -> Any? {
|
||||||
|
|
||||||
return self.bridgeToSwift.mainContext.fetchExisting(object)
|
return self.bridgeToSwift.mainContext.fetchExisting(object) as NSManagedObject?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +52,7 @@ public extension CSDataStack {
|
|||||||
@objc
|
@objc
|
||||||
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
|
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
|
||||||
|
|
||||||
return self.bridgeToSwift.mainContext.fetchExisting(objectID)
|
return self.bridgeToSwift.mainContext.fetchExisting(objectID) as NSManagedObject?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,7 +64,7 @@ public extension CSDataStack {
|
|||||||
@objc
|
@objc
|
||||||
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
|
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
|
||||||
|
|
||||||
return self.bridgeToSwift.mainContext.fetchExisting(objects)
|
return self.bridgeToSwift.mainContext.fetchExisting(objects) as [NSManagedObject]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +76,7 @@ public extension CSDataStack {
|
|||||||
@objc
|
@objc
|
||||||
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
|
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
|
||||||
|
|
||||||
return self.bridgeToSwift.mainContext.fetchExisting(objectIDs)
|
return self.bridgeToSwift.mainContext.fetchExisting(objectIDs) as [NSManagedObject]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - CSListMonitor
|
// MARK: - CSListMonitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,8 +34,9 @@ import CoreData
|
|||||||
|
|
||||||
- SeeAlso: `ListMonitor`
|
- SeeAlso: `ListMonitor`
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
@objc
|
@objc
|
||||||
public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
public final class CSListMonitor: NSObject {
|
||||||
|
|
||||||
// MARK: Public (Accessors)
|
// MARK: Public (Accessors)
|
||||||
|
|
||||||
@@ -546,7 +545,8 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
|||||||
|
|
||||||
// MARK: - ListMonitor
|
// MARK: - ListMonitor
|
||||||
|
|
||||||
extension ListMonitor: CoreStoreSwiftType {
|
@available(OSX 10.12, *)
|
||||||
|
extension ListMonitor where T: NSManagedObject {
|
||||||
|
|
||||||
// MARK: CoreStoreSwiftType
|
// MARK: CoreStoreSwiftType
|
||||||
|
|
||||||
@@ -554,6 +554,17 @@ extension ListMonitor: CoreStoreSwiftType {
|
|||||||
|
|
||||||
return CSListMonitor(self)
|
return CSListMonitor(self)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
// MARK: FilePrivate
|
||||||
|
|
||||||
|
fileprivate func downcast() -> ListMonitor<NSManagedObject> {
|
||||||
|
|
||||||
|
@inline(__always)
|
||||||
|
func noWarnUnsafeBitCast<T, U>(_ x: T, to type: U.Type) -> U {
|
||||||
|
|
||||||
|
return unsafeBitCast(x, to: type)
|
||||||
|
}
|
||||||
|
return noWarnUnsafeBitCast(self, to: ListMonitor<NSManagedObject>.self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - CSListObserver
|
// MARK: - CSListObserver
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +40,7 @@ import CoreData
|
|||||||
|
|
||||||
- SeeAlso: `ListObserver`
|
- SeeAlso: `ListObserver`
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
@objc
|
@objc
|
||||||
public protocol CSListObserver: class, AnyObject {
|
public protocol CSListObserver: class, AnyObject {
|
||||||
|
|
||||||
@@ -92,6 +91,7 @@ public protocol CSListObserver: class, AnyObject {
|
|||||||
|
|
||||||
- SeeAlso: `ListObjectObserver`
|
- SeeAlso: `ListObjectObserver`
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
@objc
|
@objc
|
||||||
public protocol CSListObjectObserver: CSListObserver {
|
public protocol CSListObjectObserver: CSListObserver {
|
||||||
|
|
||||||
@@ -152,6 +152,7 @@ public protocol CSListObjectObserver: CSListObserver {
|
|||||||
|
|
||||||
- SeeAlso: `ListSectionObserver`
|
- SeeAlso: `ListSectionObserver`
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
@objc
|
@objc
|
||||||
public protocol CSListSectionObserver: CSListObjectObserver {
|
public protocol CSListSectionObserver: CSListObjectObserver {
|
||||||
|
|
||||||
@@ -175,5 +176,3 @@ public protocol CSListSectionObserver: CSListObjectObserver {
|
|||||||
@objc
|
@objc
|
||||||
optional func listMonitor(_ monitor: CSListMonitor, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int)
|
optional func listMonitor(_ monitor: CSListMonitor, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - CSObjectMonitor
|
// MARK: - CSObjectMonitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,8 +34,9 @@ import CoreData
|
|||||||
|
|
||||||
- SeeAlso: `ObjectMonitor`
|
- SeeAlso: `ObjectMonitor`
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
@objc
|
@objc
|
||||||
public final class CSObjectMonitor: NSObject, CoreStoreObjectiveCType {
|
public final class CSObjectMonitor: NSObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the `NSManagedObject` instance being observed, or `nil` if the object was already deleted.
|
Returns the `NSManagedObject` instance being observed, or `nil` if the object was already deleted.
|
||||||
@@ -138,7 +137,8 @@ public final class CSObjectMonitor: NSObject, CoreStoreObjectiveCType {
|
|||||||
|
|
||||||
// MARK: - ObjectMonitor
|
// MARK: - ObjectMonitor
|
||||||
|
|
||||||
extension ObjectMonitor: CoreStoreSwiftType {
|
@available(OSX 10.12, *)
|
||||||
|
extension ObjectMonitor where EntityType: NSManagedObject {
|
||||||
|
|
||||||
// MARK: CoreStoreSwiftType
|
// MARK: CoreStoreSwiftType
|
||||||
|
|
||||||
@@ -146,6 +146,17 @@ extension ObjectMonitor: CoreStoreSwiftType {
|
|||||||
|
|
||||||
return CSObjectMonitor(self)
|
return CSObjectMonitor(self)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
// MARK: FilePrivate
|
||||||
|
|
||||||
|
fileprivate func downcast() -> ObjectMonitor<NSManagedObject> {
|
||||||
|
|
||||||
|
@inline(__always)
|
||||||
|
func noWarnUnsafeBitCast<T, U>(_ x: T, to type: U.Type) -> U {
|
||||||
|
|
||||||
|
return unsafeBitCast(x, to: type)
|
||||||
|
}
|
||||||
|
return noWarnUnsafeBitCast(self, to: ObjectMonitor<NSManagedObject>.self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - CSObjectObserver
|
// MARK: - CSObjectObserver
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +38,7 @@ import CoreData
|
|||||||
|
|
||||||
- SeeAlso: `ObjectObserver`
|
- SeeAlso: `ObjectObserver`
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
@objc
|
@objc
|
||||||
public protocol CSObjectObserver: class, AnyObject {
|
public protocol CSObjectObserver: class, AnyObject {
|
||||||
|
|
||||||
@@ -71,5 +70,3 @@ public protocol CSObjectObserver: class, AnyObject {
|
|||||||
@objc
|
@objc
|
||||||
optional func objectMonitor(_ monitor: CSObjectMonitor, didDeleteObject object: Any)
|
optional func objectMonitor(_ monitor: CSObjectMonitor, didDeleteObject object: Any)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - CSSectionBy
|
// MARK: - CSSectionBy
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,6 +34,7 @@ import CoreData
|
|||||||
|
|
||||||
- SeeAlso: `SectionBy`
|
- SeeAlso: `SectionBy`
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
@objc
|
@objc
|
||||||
public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
|
public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
|
||||||
|
|
||||||
@@ -87,6 +86,7 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
|
|||||||
|
|
||||||
// MARK: - SectionBy
|
// MARK: - SectionBy
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
extension SectionBy: CoreStoreSwiftType {
|
extension SectionBy: CoreStoreSwiftType {
|
||||||
|
|
||||||
// MARK: CoreStoreSwiftType
|
// MARK: CoreStoreSwiftType
|
||||||
@@ -96,5 +96,3 @@ extension SectionBy: CoreStoreSwiftType {
|
|||||||
return CSSectionBy(self)
|
return CSSectionBy(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - CSDataStack
|
// MARK: - CSDataStack
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension CSDataStack {
|
public extension CSDataStack {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,6 +56,7 @@ public extension CSDataStack {
|
|||||||
|
|
||||||
// MARK: - CSUnsafeDataTransaction
|
// MARK: - CSUnsafeDataTransaction
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension CSUnsafeDataTransaction {
|
public extension CSUnsafeDataTransaction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,6 +83,7 @@ public extension CSUnsafeDataTransaction {
|
|||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
fileprivate func createFRC(fromContext context: NSManagedObjectContext, from: CSFrom? = nil, sectionBy: CSSectionBy?, fetchClauses: [CSFetchClause]) -> NSFetchedResultsController<NSManagedObject> {
|
fileprivate func createFRC(fromContext context: NSManagedObjectContext, from: CSFrom? = nil, sectionBy: CSSectionBy?, fetchClauses: [CSFetchClause]) -> NSFetchedResultsController<NSManagedObject> {
|
||||||
|
|
||||||
let controller = CoreStoreFetchedResultsController(
|
let controller = CoreStoreFetchedResultsController(
|
||||||
@@ -102,5 +103,3 @@ fileprivate func createFRC(fromContext context: NSManagedObjectContext, from: CS
|
|||||||
)
|
)
|
||||||
return controller.dynamicCast()
|
return controller.dynamicCast()
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ public extension NSManagedObject {
|
|||||||
- returns: the primitive value for the KVC key
|
- returns: the primitive value for the KVC key
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public func cs_accessValueForKVCKey(_ KVCKey: KeyPath) -> Any? {
|
public func cs_accessValueForKVCKey(_ kvcKey: KeyPath) -> Any? {
|
||||||
|
|
||||||
return self.accessValueForKVCKey(KVCKey)
|
return self.getValue(forKvcKey: kvcKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +52,7 @@ public extension NSManagedObject {
|
|||||||
@objc
|
@objc
|
||||||
public func cs_setValue(_ value: Any?, forKVCKey KVCKey: KeyPath) {
|
public func cs_setValue(_ value: Any?, forKVCKey KVCKey: KeyPath) {
|
||||||
|
|
||||||
self.setValue(value, forKVCKey: KVCKey)
|
self.setValue(value, forKvcKey: KVCKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - CoreStore
|
// MARK: - CoreStore
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension CoreStore {
|
public extension CoreStore {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,5 +143,3 @@ public extension CoreStore {
|
|||||||
self.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
|
self.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - DataStack
|
// MARK: - DataStack
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension DataStack {
|
public extension DataStack {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,5 +219,3 @@ public extension DataStack {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - ListMonitor
|
// MARK: - ListMonitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,7 +66,8 @@ import CoreData
|
|||||||
```
|
```
|
||||||
In the example above, both `person1` and `person2` will contain the object at section=2, index=3.
|
In the example above, both `person1` and `person2` will contain the object at section=2, index=3.
|
||||||
*/
|
*/
|
||||||
public final class ListMonitor<T: NSManagedObject>: Hashable {
|
@available(OSX 10.12, *)
|
||||||
|
public final class ListMonitor<T: DynamicObject>: Hashable {
|
||||||
|
|
||||||
// MARK: Public (Accessors)
|
// MARK: Public (Accessors)
|
||||||
|
|
||||||
@@ -80,7 +79,15 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
*/
|
*/
|
||||||
public subscript(index: Int) -> T {
|
public subscript(index: Int) -> T {
|
||||||
|
|
||||||
return self.objectsInAllSections()[index]
|
CoreStore.assert(
|
||||||
|
!self.isPendingRefetch || Thread.isMainThread,
|
||||||
|
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
||||||
|
)
|
||||||
|
if self.isSectioned {
|
||||||
|
|
||||||
|
return T.cs_fromRaw(object: self.fetchedResultsController.fetchedObjects![index])
|
||||||
|
}
|
||||||
|
return self[0, index]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,12 +98,16 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
*/
|
*/
|
||||||
public subscript(safeIndex index: Int) -> T? {
|
public subscript(safeIndex index: Int) -> T? {
|
||||||
|
|
||||||
let objects = self.objectsInAllSections()
|
if self.isSectioned {
|
||||||
guard objects.indices.contains(index) else {
|
|
||||||
|
|
||||||
|
let fetchedObjects = self.fetchedResultsController.fetchedObjects!
|
||||||
|
if index < fetchedObjects.count && index >= 0 {
|
||||||
|
|
||||||
|
return T.cs_fromRaw(object: fetchedObjects[index])
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return objects[index]
|
return self[safeSectionIndex: 0, safeItemIndex: index]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,7 +139,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return section.objects?[itemIndex] as? T
|
return T.cs_fromRaw(object: section.objects![itemIndex] as! NSManagedObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,7 +154,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
!self.isPendingRefetch || Thread.isMainThread,
|
!self.isPendingRefetch || Thread.isMainThread,
|
||||||
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
||||||
)
|
)
|
||||||
return self.fetchedResultsController.object(at: indexPath) as! T
|
return T.cs_fromRaw(object: self.fetchedResultsController.object(at: indexPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,42 +202,6 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
return self.numberOfObjectsInSection(safeSectionIndex: section)! > 0
|
return self.numberOfObjectsInSection(safeSectionIndex: section)! > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Returns all objects in all sections
|
|
||||||
|
|
||||||
- returns: all objects in all sections
|
|
||||||
*/
|
|
||||||
public func objectsInAllSections() -> [T] {
|
|
||||||
|
|
||||||
CoreStore.assert(
|
|
||||||
!self.isPendingRefetch || Thread.isMainThread,
|
|
||||||
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
|
||||||
)
|
|
||||||
return (self.fetchedResultsController.dynamicCast() as NSFetchedResultsController<T>).fetchedObjects ?? []
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Returns all objects in the specified section
|
|
||||||
|
|
||||||
- parameter section: the section index. Using an index outside the valid range will raise an exception.
|
|
||||||
- returns: all objects in the specified section
|
|
||||||
*/
|
|
||||||
public func objectsInSection(_ section: Int) -> [T] {
|
|
||||||
|
|
||||||
return (self.sectionInfoAtIndex(section).objects as! [T]?) ?? []
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Returns all objects in the specified section, or `nil` if out of bounds.
|
|
||||||
|
|
||||||
- parameter section: the section index. Using an index outside the valid range will return `nil`.
|
|
||||||
- returns: all objects in the specified section
|
|
||||||
*/
|
|
||||||
public func objectsInSection(safeSectionIndex section: Int) -> [T]? {
|
|
||||||
|
|
||||||
return self.sectionInfoAtIndex(safeSectionIndex: section)?.objects as! [T]?
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the number of sections
|
Returns the number of sections
|
||||||
|
|
||||||
@@ -371,7 +346,11 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
!self.isPendingRefetch || Thread.isMainThread,
|
!self.isPendingRefetch || Thread.isMainThread,
|
||||||
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
||||||
)
|
)
|
||||||
return (self.fetchedResultsController.dynamicCast() as NSFetchedResultsController<T>).fetchedObjects?.index(of: object)
|
if self.isSectioned {
|
||||||
|
|
||||||
|
return self.fetchedResultsController.fetchedObjects?.index(of: object.cs_toRaw())
|
||||||
|
}
|
||||||
|
return self.fetchedResultsController.indexPath(forObject: object.cs_toRaw())?[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -386,7 +365,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
!self.isPendingRefetch || Thread.isMainThread,
|
!self.isPendingRefetch || Thread.isMainThread,
|
||||||
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
||||||
)
|
)
|
||||||
return self.fetchedResultsController.indexPath(forObject: object)
|
return self.fetchedResultsController.indexPath(forObject: object.cs_toRaw())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -596,22 +575,22 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
|
|
||||||
// MARK: Equatable
|
// MARK: Equatable
|
||||||
|
|
||||||
public static func == <T: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<T>) -> Bool {
|
public static func == (lhs: ListMonitor<T>, rhs: ListMonitor<T>) -> Bool {
|
||||||
|
|
||||||
return lhs === rhs
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func == <T: NSManagedObject, U: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<U>) -> Bool {
|
|
||||||
|
|
||||||
return lhs.fetchedResultsController === rhs.fetchedResultsController
|
return lhs.fetchedResultsController === rhs.fetchedResultsController
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func ~= <T: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<T>) -> Bool {
|
public static func == <T: DynamicObject, U: DynamicObject>(lhs: ListMonitor<T>, rhs: ListMonitor<U>) -> Bool {
|
||||||
|
|
||||||
return lhs === rhs
|
return lhs.fetchedResultsController === rhs.fetchedResultsController
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func ~= <T: NSManagedObject, U: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<U>) -> Bool {
|
public static func ~= (lhs: ListMonitor<T>, rhs: ListMonitor<T>) -> Bool {
|
||||||
|
|
||||||
|
return lhs.fetchedResultsController === rhs.fetchedResultsController
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func ~= <T: DynamicObject, U: DynamicObject>(lhs: ListMonitor<T>, rhs: ListMonitor<U>) -> Bool {
|
||||||
|
|
||||||
return lhs.fetchedResultsController === rhs.fetchedResultsController
|
return lhs.fetchedResultsController === rhs.fetchedResultsController
|
||||||
}
|
}
|
||||||
@@ -675,16 +654,6 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func downcast() -> ListMonitor<NSManagedObject> {
|
|
||||||
|
|
||||||
@inline(__always)
|
|
||||||
func noWarnUnsafeBitCast<T, U>(_ x: T, to type: U.Type) -> U {
|
|
||||||
|
|
||||||
return unsafeBitCast(x, to: type)
|
|
||||||
}
|
|
||||||
return noWarnUnsafeBitCast(self, to: ListMonitor<NSManagedObject>.self)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal func registerChangeNotification(_ notificationKey: UnsafeRawPointer, name: Notification.Name, toObserver observer: AnyObject, callback: @escaping (_ monitor: ListMonitor<T>) -> Void) {
|
internal func registerChangeNotification(_ notificationKey: UnsafeRawPointer, name: Notification.Name, toObserver observer: AnyObject, callback: @escaping (_ monitor: ListMonitor<T>) -> Void) {
|
||||||
|
|
||||||
cs_setAssociatedRetainedObject(
|
cs_setAssociatedRetainedObject(
|
||||||
@@ -1001,6 +970,8 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
fileprivate let taskGroup = DispatchGroup()
|
fileprivate let taskGroup = DispatchGroup()
|
||||||
fileprivate let sectionIndexTransformer: (_ sectionName: KeyPath?) -> String?
|
fileprivate let sectionIndexTransformer: (_ sectionName: KeyPath?) -> String?
|
||||||
|
|
||||||
|
private let isSectioned: Bool
|
||||||
|
|
||||||
private var willChangeListKey: Void?
|
private var willChangeListKey: Void?
|
||||||
private var didChangeListKey: Void?
|
private var didChangeListKey: Void?
|
||||||
private var willRefetchListKey: Void?
|
private var willRefetchListKey: Void?
|
||||||
@@ -1014,7 +985,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
private var didInsertSectionKey: Void?
|
private var didInsertSectionKey: Void?
|
||||||
private var didDeleteSectionKey: Void?
|
private var didDeleteSectionKey: Void?
|
||||||
|
|
||||||
private let fetchedResultsControllerDelegate: FetchedResultsControllerDelegate<T>
|
private let fetchedResultsControllerDelegate: FetchedResultsControllerDelegate
|
||||||
private var observerForWillChangePersistentStore: NotificationObserver!
|
private var observerForWillChangePersistentStore: NotificationObserver!
|
||||||
private var observerForDidChangePersistentStore: NotificationObserver!
|
private var observerForDidChangePersistentStore: NotificationObserver!
|
||||||
private let transactionQueue: DispatchQueue
|
private let transactionQueue: DispatchQueue
|
||||||
@@ -1043,6 +1014,8 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
|
|
||||||
private init(context: NSManagedObjectContext, transactionQueue: DispatchQueue, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: @escaping (_ 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)?) {
|
||||||
|
|
||||||
|
self.isSectioned = (sectionBy != nil)
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
fetchRequest.fetchLimit = 0
|
fetchRequest.fetchLimit = 0
|
||||||
fetchRequest.resultType = .managedObjectResultType
|
fetchRequest.resultType = .managedObjectResultType
|
||||||
@@ -1058,7 +1031,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
applyFetchClauses: applyFetchClauses
|
applyFetchClauses: applyFetchClauses
|
||||||
)
|
)
|
||||||
|
|
||||||
let fetchedResultsControllerDelegate = FetchedResultsControllerDelegate<T>()
|
let fetchedResultsControllerDelegate = FetchedResultsControllerDelegate()
|
||||||
|
|
||||||
self.fetchedResultsController = fetchedResultsController
|
self.fetchedResultsController = fetchedResultsController
|
||||||
self.fetchedResultsControllerDelegate = fetchedResultsControllerDelegate
|
self.fetchedResultsControllerDelegate = fetchedResultsControllerDelegate
|
||||||
@@ -1151,8 +1124,98 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - ListMonitor where T: NSManagedObject
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
|
extension ListMonitor where T: NSManagedObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns all objects in all sections
|
||||||
|
|
||||||
|
- returns: all objects in all sections
|
||||||
|
*/
|
||||||
|
public func objectsInAllSections() -> [T] {
|
||||||
|
|
||||||
|
CoreStore.assert(
|
||||||
|
!self.isPendingRefetch || Thread.isMainThread,
|
||||||
|
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
||||||
|
)
|
||||||
|
return (self.fetchedResultsController.dynamicCast() as NSFetchedResultsController<T>).fetchedObjects ?? []
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns all objects in the specified section
|
||||||
|
|
||||||
|
- parameter section: the section index. Using an index outside the valid range will raise an exception.
|
||||||
|
- returns: all objects in the specified section
|
||||||
|
*/
|
||||||
|
public func objectsInSection(_ section: Int) -> [T] {
|
||||||
|
|
||||||
|
return (self.sectionInfoAtIndex(section).objects as! [T]?) ?? []
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns all objects in the specified section, or `nil` if out of bounds.
|
||||||
|
|
||||||
|
- parameter section: the section index. Using an index outside the valid range will return `nil`.
|
||||||
|
- returns: all objects in the specified section
|
||||||
|
*/
|
||||||
|
public func objectsInSection(safeSectionIndex section: Int) -> [T]? {
|
||||||
|
|
||||||
|
return self.sectionInfoAtIndex(safeSectionIndex: section)?.objects as! [T]?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - ListMonitor where T: CoreStoreObject
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
|
extension ListMonitor where T: CoreStoreObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns all objects in all sections
|
||||||
|
|
||||||
|
- returns: all objects in all sections
|
||||||
|
*/
|
||||||
|
public func objectsInAllSections() -> [T] {
|
||||||
|
|
||||||
|
CoreStore.assert(
|
||||||
|
!self.isPendingRefetch || Thread.isMainThread,
|
||||||
|
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
||||||
|
)
|
||||||
|
return (self.fetchedResultsController.fetchedObjects ?? [])
|
||||||
|
.map(T.cs_fromRaw)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns all objects in the specified section
|
||||||
|
|
||||||
|
- parameter section: the section index. Using an index outside the valid range will raise an exception.
|
||||||
|
- returns: all objects in the specified section
|
||||||
|
*/
|
||||||
|
public func objectsInSection(_ section: Int) -> [T] {
|
||||||
|
|
||||||
|
return (self.sectionInfoAtIndex(section).objects ?? [])
|
||||||
|
.map({ T.cs_fromRaw(object: $0 as! NSManagedObject) })
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns all objects in the specified section, or `nil` if out of bounds.
|
||||||
|
|
||||||
|
- parameter section: the section index. Using an index outside the valid range will return `nil`.
|
||||||
|
- returns: all objects in the specified section
|
||||||
|
*/
|
||||||
|
public func objectsInSection(safeSectionIndex section: Int) -> [T]? {
|
||||||
|
|
||||||
|
return (self.sectionInfoAtIndex(safeSectionIndex: section)?.objects)?
|
||||||
|
.map({ T.cs_fromRaw(object: $0 as! NSManagedObject) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: - ListMonitor: FetchedResultsControllerHandler
|
// MARK: - ListMonitor: FetchedResultsControllerHandler
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
extension ListMonitor: FetchedResultsControllerHandler {
|
extension ListMonitor: FetchedResultsControllerHandler {
|
||||||
|
|
||||||
// MARK: FetchedResultsControllerHandler
|
// MARK: FetchedResultsControllerHandler
|
||||||
@@ -1260,6 +1323,7 @@ extension ListMonitor: FetchedResultsControllerHandler {
|
|||||||
|
|
||||||
// MARK: - Notification Keys
|
// MARK: - Notification Keys
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
fileprivate extension Notification.Name {
|
fileprivate extension Notification.Name {
|
||||||
|
|
||||||
fileprivate static let listMonitorWillChangeList = Notification.Name(rawValue: "listMonitorWillChangeList")
|
fileprivate static let listMonitorWillChangeList = Notification.Name(rawValue: "listMonitorWillChangeList")
|
||||||
@@ -1273,5 +1337,3 @@ fileprivate extension Notification.Name {
|
|||||||
fileprivate static let listMonitorDidInsertSection = Notification.Name(rawValue: "listMonitorDidInsertSection")
|
fileprivate static let listMonitorDidInsertSection = Notification.Name(rawValue: "listMonitorDidInsertSection")
|
||||||
fileprivate static let listMonitorDidDeleteSection = Notification.Name(rawValue: "listMonitorDidDeleteSection")
|
fileprivate static let listMonitorDidDeleteSection = Notification.Name(rawValue: "listMonitorDidDeleteSection")
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - ListObserver
|
// MARK: - ListObserver
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,12 +39,13 @@ import CoreData
|
|||||||
monitor.addObserver(self)
|
monitor.addObserver(self)
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public protocol ListObserver: class {
|
public protocol ListObserver: class {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The `NSManagedObject` type for the observed list
|
The `NSManagedObject` type for the observed list
|
||||||
*/
|
*/
|
||||||
associatedtype ListEntityType: NSManagedObject
|
associatedtype ListEntityType: DynamicObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handles processing just before a change to the observed list occurs. (Optional)
|
Handles processing just before a change to the observed list occurs. (Optional)
|
||||||
@@ -85,6 +84,7 @@ public protocol ListObserver: class {
|
|||||||
|
|
||||||
// MARK: - ListObserver (Default Implementations)
|
// MARK: - ListObserver (Default Implementations)
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension ListObserver {
|
public extension ListObserver {
|
||||||
|
|
||||||
public func listMonitorWillChange(_ monitor: ListMonitor<ListEntityType>) { }
|
public func listMonitorWillChange(_ monitor: ListMonitor<ListEntityType>) { }
|
||||||
@@ -109,6 +109,7 @@ public extension ListObserver {
|
|||||||
monitor.addObserver(self)
|
monitor.addObserver(self)
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public protocol ListObjectObserver: ListObserver {
|
public protocol ListObjectObserver: ListObserver {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,6 +157,7 @@ public protocol ListObjectObserver: ListObserver {
|
|||||||
|
|
||||||
// MARK: - ListObjectObserver (Default Implementations)
|
// MARK: - ListObjectObserver (Default Implementations)
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension ListObjectObserver {
|
public extension ListObjectObserver {
|
||||||
|
|
||||||
public func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertObject object: ListEntityType, toIndexPath indexPath: IndexPath) { }
|
public func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertObject object: ListEntityType, toIndexPath indexPath: IndexPath) { }
|
||||||
@@ -181,6 +183,7 @@ public extension ListObjectObserver {
|
|||||||
monitor.addObserver(self)
|
monitor.addObserver(self)
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public protocol ListSectionObserver: ListObjectObserver {
|
public protocol ListSectionObserver: ListObjectObserver {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -207,11 +210,10 @@ public protocol ListSectionObserver: ListObjectObserver {
|
|||||||
|
|
||||||
// MARK: - ListSectionObserver (Default Implementations)
|
// MARK: - ListSectionObserver (Default Implementations)
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension ListSectionObserver {
|
public extension ListSectionObserver {
|
||||||
|
|
||||||
public func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int) { }
|
public func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int) { }
|
||||||
|
|
||||||
public func listMonitor(_ monitor: ListMonitor<ListEntityType>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) { }
|
public func listMonitor(_ monitor: ListMonitor<ListEntityType>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - ObjectMonitor
|
// MARK: - ObjectMonitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,14 +39,18 @@ import CoreData
|
|||||||
|
|
||||||
Observers registered via `addObserver(_:)` are not retained. `ObjectMonitor` only keeps a `weak` reference to all observers, thus keeping itself free from retain-cycles.
|
Observers registered via `addObserver(_:)` are not retained. `ObjectMonitor` only keeps a `weak` reference to all observers, thus keeping itself free from retain-cycles.
|
||||||
*/
|
*/
|
||||||
public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
|
@available(OSX 10.12, *)
|
||||||
|
public final class ObjectMonitor<EntityType: DynamicObject>: Equatable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the `NSManagedObject` instance being observed, or `nil` if the object was already deleted.
|
Returns the `NSManagedObject` instance being observed, or `nil` if the object was already deleted.
|
||||||
*/
|
*/
|
||||||
public var object: EntityType? {
|
public var object: EntityType? {
|
||||||
|
|
||||||
return self.fetchedResultsController.fetchedObjects?.first as? EntityType
|
return self.fetchedResultsController
|
||||||
|
.fetchedObjects?
|
||||||
|
.first
|
||||||
|
.flatMap({ EntityType.cs_fromRaw(object: $0) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,7 +58,7 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
|
|||||||
*/
|
*/
|
||||||
public var isObjectDeleted: Bool {
|
public var isObjectDeleted: Bool {
|
||||||
|
|
||||||
return self.object?.managedObjectContext == nil
|
return self.object?.cs_toRaw().managedObjectContext == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,22 +107,22 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
|
|||||||
|
|
||||||
// MARK: Equatable
|
// MARK: Equatable
|
||||||
|
|
||||||
public static func == <T: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<T>) -> Bool {
|
public static func == <T: DynamicObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<T>) -> Bool {
|
||||||
|
|
||||||
return lhs === rhs
|
return lhs === rhs
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func == <T: NSManagedObject, U: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<U>) -> Bool {
|
public static func == <T: DynamicObject, U: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<U>) -> Bool {
|
||||||
|
|
||||||
return lhs.fetchedResultsController === rhs.fetchedResultsController
|
return lhs.fetchedResultsController === rhs.fetchedResultsController
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func ~= <T: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<T>) -> Bool {
|
public static func ~= <T: DynamicObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<T>) -> Bool {
|
||||||
|
|
||||||
return lhs === rhs
|
return lhs === rhs
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func ~= <T: NSManagedObject, U: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<U>) -> Bool {
|
public static func ~= <T: DynamicObject, U: DynamicObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<U>) -> Bool {
|
||||||
|
|
||||||
return lhs.fetchedResultsController === rhs.fetchedResultsController
|
return lhs.fetchedResultsController === rhs.fetchedResultsController
|
||||||
}
|
}
|
||||||
@@ -190,7 +192,7 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let previousCommitedAttributes = self.lastCommittedAttributes
|
let previousCommitedAttributes = self.lastCommittedAttributes
|
||||||
let currentCommitedAttributes = object.committedValues(forKeys: nil) as! [String: NSObject]
|
let currentCommitedAttributes = object.cs_toRaw().committedValues(forKeys: nil) as! [String: NSObject]
|
||||||
|
|
||||||
var changedKeys = Set<String>()
|
var changedKeys = Set<String>()
|
||||||
for key in currentCommitedAttributes.keys {
|
for key in currentCommitedAttributes.keys {
|
||||||
@@ -220,16 +222,6 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
|
|||||||
cs_setAssociatedRetainedObject(nilValue, forKey: &self.didUpdateObjectKey, inObject: observer)
|
cs_setAssociatedRetainedObject(nilValue, forKey: &self.didUpdateObjectKey, inObject: observer)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func downcast() -> ObjectMonitor<NSManagedObject> {
|
|
||||||
|
|
||||||
@inline(__always)
|
|
||||||
func noWarnUnsafeBitCast<T, U>(_ x: T, to type: U.Type) -> U {
|
|
||||||
|
|
||||||
return unsafeBitCast(x, to: type)
|
|
||||||
}
|
|
||||||
return noWarnUnsafeBitCast(self, to: ObjectMonitor<NSManagedObject>.self)
|
|
||||||
}
|
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
|
|
||||||
self.fetchedResultsControllerDelegate.fetchedResultsController = nil
|
self.fetchedResultsControllerDelegate.fetchedResultsController = nil
|
||||||
@@ -239,7 +231,7 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
|
|||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
private let fetchedResultsController: CoreStoreFetchedResultsController
|
private let fetchedResultsController: CoreStoreFetchedResultsController
|
||||||
private let fetchedResultsControllerDelegate: FetchedResultsControllerDelegate<EntityType>
|
private let fetchedResultsControllerDelegate: FetchedResultsControllerDelegate
|
||||||
private var lastCommittedAttributes = [String: NSObject]()
|
private var lastCommittedAttributes = [String: NSObject]()
|
||||||
|
|
||||||
private var willChangeObjectKey: Void?
|
private var willChangeObjectKey: Void?
|
||||||
@@ -248,22 +240,24 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
|
|||||||
|
|
||||||
private init(context: NSManagedObjectContext, object: EntityType) {
|
private init(context: NSManagedObjectContext, object: EntityType) {
|
||||||
|
|
||||||
|
let rawObject = object.cs_toRaw()
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
fetchRequest.entity = object.entity
|
fetchRequest.entity = rawObject.entity
|
||||||
fetchRequest.fetchLimit = 0
|
fetchRequest.fetchLimit = 0
|
||||||
fetchRequest.resultType = .managedObjectResultType
|
fetchRequest.resultType = .managedObjectResultType
|
||||||
fetchRequest.sortDescriptors = []
|
fetchRequest.sortDescriptors = []
|
||||||
fetchRequest.includesPendingChanges = false
|
fetchRequest.includesPendingChanges = false
|
||||||
fetchRequest.shouldRefreshRefetchedObjects = true
|
fetchRequest.shouldRefreshRefetchedObjects = true
|
||||||
|
|
||||||
let objectID = object.objectID
|
let objectID = rawObject.objectID
|
||||||
let fetchedResultsController = CoreStoreFetchedResultsController(
|
let fetchedResultsController = CoreStoreFetchedResultsController(
|
||||||
context: context,
|
context: context,
|
||||||
fetchRequest: fetchRequest.dynamicCast(),
|
fetchRequest: fetchRequest.dynamicCast(),
|
||||||
|
from: nil as From<EntityType>?,
|
||||||
applyFetchClauses: Where("SELF", isEqualTo: objectID).applyToFetchRequest
|
applyFetchClauses: Where("SELF", isEqualTo: objectID).applyToFetchRequest
|
||||||
)
|
)
|
||||||
|
|
||||||
let fetchedResultsControllerDelegate = FetchedResultsControllerDelegate<EntityType>()
|
let fetchedResultsControllerDelegate = FetchedResultsControllerDelegate()
|
||||||
|
|
||||||
self.fetchedResultsController = fetchedResultsController
|
self.fetchedResultsController = fetchedResultsController
|
||||||
self.fetchedResultsControllerDelegate = fetchedResultsControllerDelegate
|
self.fetchedResultsControllerDelegate = fetchedResultsControllerDelegate
|
||||||
@@ -272,7 +266,7 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
|
|||||||
fetchedResultsControllerDelegate.fetchedResultsController = fetchedResultsController
|
fetchedResultsControllerDelegate.fetchedResultsController = fetchedResultsController
|
||||||
try! fetchedResultsController.performFetchFromSpecifiedStores()
|
try! fetchedResultsController.performFetchFromSpecifiedStores()
|
||||||
|
|
||||||
self.lastCommittedAttributes = (self.object?.committedValues(forKeys: nil) as? [String: NSObject]) ?? [:]
|
self.lastCommittedAttributes = (self.object?.cs_toRaw().committedValues(forKeys: nil) as? [String: NSObject]) ?? [:]
|
||||||
}
|
}
|
||||||
|
|
||||||
private func registerChangeNotification(_ notificationKey: UnsafeRawPointer, name: Notification.Name, toObserver observer: AnyObject, callback: @escaping (_ monitor: ObjectMonitor<EntityType>) -> Void) {
|
private func registerChangeNotification(_ notificationKey: UnsafeRawPointer, name: Notification.Name, toObserver observer: AnyObject, callback: @escaping (_ monitor: ObjectMonitor<EntityType>) -> Void) {
|
||||||
@@ -281,7 +275,7 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
|
|||||||
NotificationObserver(
|
NotificationObserver(
|
||||||
notificationName: name,
|
notificationName: name,
|
||||||
object: self,
|
object: self,
|
||||||
closure: { [weak self] (note) -> Void in
|
closure: { [weak self] _ in
|
||||||
|
|
||||||
guard let `self` = self else {
|
guard let `self` = self else {
|
||||||
|
|
||||||
@@ -301,15 +295,15 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
|
|||||||
NotificationObserver(
|
NotificationObserver(
|
||||||
notificationName: name,
|
notificationName: name,
|
||||||
object: self,
|
object: self,
|
||||||
closure: { [weak self] (note) -> Void in
|
closure: { [weak self] (note) in
|
||||||
|
|
||||||
guard let `self` = self,
|
guard let `self` = self,
|
||||||
let userInfo = note.userInfo,
|
let userInfo = note.userInfo,
|
||||||
let object = userInfo[String(describing: NSManagedObject.self)] as? EntityType else {
|
let object = userInfo[String(describing: NSManagedObject.self)] as! NSManagedObject? else {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
callback(self, object)
|
callback(self, EntityType.cs_fromRaw(object: object))
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
forKey: notificationKey,
|
forKey: notificationKey,
|
||||||
@@ -321,6 +315,7 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
|
|||||||
|
|
||||||
// MARK: - ObjectMonitor: FetchedResultsControllerHandler
|
// MARK: - ObjectMonitor: FetchedResultsControllerHandler
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
extension ObjectMonitor: FetchedResultsControllerHandler {
|
extension ObjectMonitor: FetchedResultsControllerHandler {
|
||||||
|
|
||||||
// MARK: FetchedResultsControllerHandler
|
// MARK: FetchedResultsControllerHandler
|
||||||
@@ -370,11 +365,10 @@ extension ObjectMonitor: FetchedResultsControllerHandler {
|
|||||||
|
|
||||||
// MARK: - Notification.Name
|
// MARK: - Notification.Name
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
fileprivate extension Notification.Name {
|
fileprivate extension Notification.Name {
|
||||||
|
|
||||||
fileprivate static let objectMonitorWillChangeObject = Notification.Name(rawValue: "objectMonitorWillChangeObject")
|
fileprivate static let objectMonitorWillChangeObject = Notification.Name(rawValue: "objectMonitorWillChangeObject")
|
||||||
fileprivate static let objectMonitorDidDeleteObject = Notification.Name(rawValue: "objectMonitorDidDeleteObject")
|
fileprivate static let objectMonitorDidDeleteObject = Notification.Name(rawValue: "objectMonitorDidDeleteObject")
|
||||||
fileprivate static let objectMonitorDidUpdateObject = Notification.Name(rawValue: "objectMonitorDidUpdateObject")
|
fileprivate static let objectMonitorDidUpdateObject = Notification.Name(rawValue: "objectMonitorDidUpdateObject")
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - ObjectObserver
|
// MARK: - ObjectObserver
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,12 +36,13 @@ import CoreData
|
|||||||
monitor.addObserver(self)
|
monitor.addObserver(self)
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public protocol ObjectObserver: class {
|
public protocol ObjectObserver: class {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The `NSManagedObject` type for the observed object
|
The `NSManagedObject` type for the observed object
|
||||||
*/
|
*/
|
||||||
associatedtype ObjectEntityType: NSManagedObject
|
associatedtype ObjectEntityType: DynamicObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handles processing just before a change to the observed `object` occurs. (Optional)
|
Handles processing just before a change to the observed `object` occurs. (Optional)
|
||||||
@@ -77,6 +76,7 @@ public protocol ObjectObserver: class {
|
|||||||
|
|
||||||
// MARK: - ObjectObserver (Default Implementations)
|
// MARK: - ObjectObserver (Default Implementations)
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension ObjectObserver {
|
public extension ObjectObserver {
|
||||||
|
|
||||||
public func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType) { }
|
public func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType) { }
|
||||||
@@ -85,5 +85,3 @@ public extension ObjectObserver {
|
|||||||
|
|
||||||
public func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType) { }
|
public func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - SectionBy
|
// MARK: - SectionBy
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,6 +39,7 @@ import CoreData
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public struct SectionBy {
|
public struct SectionBy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,5 +71,3 @@ public struct SectionBy {
|
|||||||
internal let sectionKeyPath: KeyPath
|
internal let sectionKeyPath: KeyPath
|
||||||
internal let sectionIndexTransformer: (_ sectionName: String?) -> String?
|
internal let sectionIndexTransformer: (_ sectionName: String?) -> String?
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
|
||||||
|
|
||||||
// MARK: - UnsafeDataTransaction
|
// MARK: - UnsafeDataTransaction
|
||||||
|
|
||||||
|
@available(OSX 10.12, *)
|
||||||
public extension UnsafeDataTransaction {
|
public extension UnsafeDataTransaction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,5 +200,3 @@ public extension UnsafeDataTransaction {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public extension CoreStore {
|
|||||||
/**
|
/**
|
||||||
Returns the entity name-to-class type mapping from the `defaultStack`'s model.
|
Returns the entity name-to-class type mapping from the `defaultStack`'s model.
|
||||||
*/
|
*/
|
||||||
public static func entityTypesByName(for type: ManagedObject.Type) -> [EntityName: ManagedObject.Type] {
|
public static func entityTypesByName(for type: CoreStoreObject.Type) -> [EntityName: CoreStoreObject.Type] {
|
||||||
|
|
||||||
return self.defaultStack.entityTypesByName(for: type)
|
return self.defaultStack.entityTypesByName(for: type)
|
||||||
}
|
}
|
||||||
@@ -64,9 +64,9 @@ public extension CoreStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the `NSEntityDescription` for the specified `ManagedObject` subclass from `defaultStack`'s model.
|
Returns the `NSEntityDescription` for the specified `CoreStoreObject` subclass from `defaultStack`'s model.
|
||||||
*/
|
*/
|
||||||
public static func entityDescription(for type: ManagedObject.Type) -> NSEntityDescription? {
|
public static func entityDescription(for type: CoreStoreObject.Type) -> NSEntityDescription? {
|
||||||
|
|
||||||
return self.defaultStack.entityDescription(for: type)
|
return self.defaultStack.entityDescription(for: type)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,12 +51,12 @@ public final class DataStack: Equatable {
|
|||||||
self.init(model: model, migrationChain: migrationChain)
|
self.init(model: model, migrationChain: migrationChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
public convenience init(dynamicModel: ObjectModel) {
|
public convenience init(dynamicModel: DynamicModel) {
|
||||||
|
|
||||||
self.init(model: dynamicModel.createModel())
|
self.init(model: dynamicModel.createModel())
|
||||||
}
|
}
|
||||||
|
|
||||||
public convenience init(dynamicModels: [ObjectModel], migrationChain: MigrationChain = nil) {
|
public convenience init(dynamicModels: [DynamicModel], migrationChain: MigrationChain = nil) {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
migrationChain.valid,
|
migrationChain.valid,
|
||||||
@@ -130,9 +130,9 @@ public final class DataStack: Equatable {
|
|||||||
/**
|
/**
|
||||||
Returns the entity name-to-class type mapping from the `DataStack`'s model.
|
Returns the entity name-to-class type mapping from the `DataStack`'s model.
|
||||||
*/
|
*/
|
||||||
public func entityTypesByName(for type: ManagedObject.Type) -> [EntityName: ManagedObject.Type] {
|
public func entityTypesByName(for type: CoreStoreObject.Type) -> [EntityName: CoreStoreObject.Type] {
|
||||||
|
|
||||||
var entityTypesByName: [EntityName: ManagedObject.Type] = [:]
|
var entityTypesByName: [EntityName: CoreStoreObject.Type] = [:]
|
||||||
for (entityIdentifier, entityDescription) in self.model.entityDescriptionsByEntityIdentifier {
|
for (entityIdentifier, entityDescription) in self.model.entityDescriptionsByEntityIdentifier {
|
||||||
|
|
||||||
switch entityIdentifier.category {
|
switch entityIdentifier.category {
|
||||||
@@ -141,7 +141,11 @@ public final class DataStack: Equatable {
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
case .coreStore:
|
case .coreStore:
|
||||||
let actualType = NSClassFromString(entityDescription.managedObjectClassName!)! as! ManagedObject.Type
|
guard let anyEntity = entityDescription.anyEntity else {
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
let actualType = anyEntity.type
|
||||||
if (actualType as AnyClass).isSubclass(of: type) {
|
if (actualType as AnyClass).isSubclass(of: type) {
|
||||||
|
|
||||||
entityTypesByName[entityDescription.name!] = actualType
|
entityTypesByName[entityDescription.name!] = actualType
|
||||||
@@ -160,9 +164,9 @@ public final class DataStack: Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the `NSEntityDescription` for the specified `ManagedObject` subclass.
|
Returns the `NSEntityDescription` for the specified `CoreStoreObject` subclass.
|
||||||
*/
|
*/
|
||||||
public func entityDescription(for type: ManagedObject.Type) -> NSEntityDescription? {
|
public func entityDescription(for type: CoreStoreObject.Type) -> NSEntityDescription? {
|
||||||
|
|
||||||
return self.entityDescription(for: EntityIdentifier(type))
|
return self.entityDescription(for: EntityIdentifier(type))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// ManagedObject.swift
|
// CoreStoreObject.swift
|
||||||
// CoreStore
|
// CoreStore
|
||||||
//
|
//
|
||||||
// Copyright © 2017 John Rommel Estropia
|
// Copyright © 2017 John Rommel Estropia
|
||||||
@@ -27,9 +27,9 @@ import CoreData
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
// MARK: - ManagedObject
|
// MARK: - CoreStoreObject
|
||||||
|
|
||||||
open class ManagedObject: ManagedObjectProtocol, Hashable {
|
open class CoreStoreObject: DynamicObject, Hashable {
|
||||||
|
|
||||||
public required init(_ object: NSManagedObject) {
|
public required init(_ object: NSManagedObject) {
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ open class ManagedObject: ManagedObjectProtocol, Hashable {
|
|||||||
|
|
||||||
// MARK: Equatable
|
// MARK: Equatable
|
||||||
|
|
||||||
public static func == (lhs: ManagedObject, rhs: ManagedObject) -> Bool {
|
public static func == (lhs: CoreStoreObject, rhs: CoreStoreObject) -> Bool {
|
||||||
|
|
||||||
guard lhs.isMeta == rhs.isMeta else {
|
guard lhs.isMeta == rhs.isMeta else {
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// ObjectModel.swift
|
// DynamicModel.swift
|
||||||
// CoreStore
|
// CoreStore
|
||||||
//
|
//
|
||||||
// Copyright © 2017 John Rommel Estropia
|
// Copyright © 2017 John Rommel Estropia
|
||||||
@@ -27,9 +27,9 @@ import CoreGraphics
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
// MARK: - ObjectModel
|
// MARK: - DynamicModel
|
||||||
|
|
||||||
public final class ObjectModel {
|
public final class DynamicModel {
|
||||||
|
|
||||||
public convenience init(version: String, entities: [EntityProtocol]) {
|
public convenience init(version: String, entities: [EntityProtocol]) {
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public final class ObjectModel {
|
|||||||
self.entityName = entity.entityName
|
self.entityName = entity.entityName
|
||||||
}
|
}
|
||||||
|
|
||||||
internal init(type: ManagedObject.Type, entityName: String) {
|
internal init(type: CoreStoreObject.Type, entityName: String) {
|
||||||
|
|
||||||
self.type = type
|
self.type = type
|
||||||
self.entityName = entityName
|
self.entityName = entityName
|
||||||
@@ -99,7 +99,7 @@ public final class ObjectModel {
|
|||||||
|
|
||||||
// MARK: EntityProtocol
|
// MARK: EntityProtocol
|
||||||
|
|
||||||
internal let type: ManagedObject.Type
|
internal let type: CoreStoreObject.Type
|
||||||
internal let entityName: EntityName
|
internal let entityName: EntityName
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,12 +116,12 @@ public final class ObjectModel {
|
|||||||
|
|
||||||
let entityDescription = ModelCache.entityDescription(
|
let entityDescription = ModelCache.entityDescription(
|
||||||
for: entity,
|
for: entity,
|
||||||
initializer: ObjectModel.firstPassCreateEntityDescription
|
initializer: DynamicModel.firstPassCreateEntityDescription
|
||||||
)
|
)
|
||||||
entityDescriptionsByEntity[entity] = entityDescription
|
entityDescriptionsByEntity[entity] = entityDescription
|
||||||
}
|
}
|
||||||
ObjectModel.secondPassConnectRelationshipAttributes(for: entityDescriptionsByEntity)
|
DynamicModel.secondPassConnectRelationshipAttributes(for: entityDescriptionsByEntity)
|
||||||
ObjectModel.thirdPassConnectInheritanceTree(for: entityDescriptionsByEntity)
|
DynamicModel.thirdPassConnectInheritanceTree(for: entityDescriptionsByEntity)
|
||||||
return entityDescriptionsByEntity
|
return entityDescriptionsByEntity
|
||||||
}
|
}
|
||||||
model.entities = entityDescriptionsByEntity.values.sorted(by: { $0.name! < $1.name! })
|
model.entities = entityDescriptionsByEntity.values.sorted(by: { $0.name! < $1.name! })
|
||||||
@@ -147,7 +147,7 @@ public final class ObjectModel {
|
|||||||
entityDescription.name = entity.entityName
|
entityDescription.name = entity.entityName
|
||||||
entityDescription.managedObjectClassName = NSStringFromClass(NSManagedObject.self)
|
entityDescription.managedObjectClassName = NSStringFromClass(NSManagedObject.self)
|
||||||
|
|
||||||
func createProperties(for type: ManagedObject.Type) -> [NSPropertyDescription] {
|
func createProperties(for type: CoreStoreObject.Type) -> [NSPropertyDescription] {
|
||||||
|
|
||||||
var propertyDescriptions: [NSPropertyDescription] = []
|
var propertyDescriptions: [NSPropertyDescription] = []
|
||||||
for child in Mirror(reflecting: type.meta).children {
|
for child in Mirror(reflecting: type.meta).children {
|
||||||
@@ -161,9 +161,8 @@ public final class ObjectModel {
|
|||||||
description.isOptional = attribute.isOptional
|
description.isOptional = attribute.isOptional
|
||||||
description.isIndexed = attribute.isIndexed
|
description.isIndexed = attribute.isIndexed
|
||||||
description.defaultValue = attribute.defaultValue
|
description.defaultValue = attribute.defaultValue
|
||||||
description.isTransient = false
|
description.isTransient = attribute.isTransient
|
||||||
// TODO: versionHash, renamingIdentifier, etc
|
// TODO: versionHash, renamingIdentifier, etc
|
||||||
// TODO: Separate attributes for Value, Transient, Relationship
|
|
||||||
propertyDescriptions.append(description)
|
propertyDescriptions.append(description)
|
||||||
|
|
||||||
case let relationship as RelationshipProtocol:
|
case let relationship as RelationshipProtocol:
|
||||||
@@ -174,7 +173,6 @@ public final class ObjectModel {
|
|||||||
description.isOrdered = relationship.isOrdered
|
description.isOrdered = relationship.isOrdered
|
||||||
description.deleteRule = relationship.deleteRule
|
description.deleteRule = relationship.deleteRule
|
||||||
// TODO: versionHash, renamingIdentifier, etc
|
// TODO: versionHash, renamingIdentifier, etc
|
||||||
// TODO: Separate attributes for Value, Transient, Relationship
|
|
||||||
propertyDescriptions.append(description)
|
propertyDescriptions.append(description)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -195,7 +193,7 @@ public final class ObjectModel {
|
|||||||
|
|
||||||
relationshipsByNameByEntity[entity] = entityDescription.relationshipsByName
|
relationshipsByNameByEntity[entity] = entityDescription.relationshipsByName
|
||||||
}
|
}
|
||||||
func findEntity(for type: ManagedObject.Type) -> AnyEntity {
|
func findEntity(for type: CoreStoreObject.Type) -> AnyEntity {
|
||||||
|
|
||||||
var matchedEntities: Set<AnyEntity> = []
|
var matchedEntities: Set<AnyEntity> = []
|
||||||
for (entity, _) in entityDescriptionsByEntity where entity.type == type {
|
for (entity, _) in entityDescriptionsByEntity where entity.type == type {
|
||||||
@@ -209,7 +207,7 @@ public final class ObjectModel {
|
|||||||
if matchedEntities.isEmpty {
|
if matchedEntities.isEmpty {
|
||||||
|
|
||||||
CoreStore.abort(
|
CoreStore.abort(
|
||||||
"No \(cs_typeName("Entity<\(type)>")) instance found in the \(cs_typeName(ObjectModel.self))."
|
"No \(cs_typeName("Entity<\(type)>")) instance found in the \(cs_typeName(DynamicModel.self))."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -244,7 +242,7 @@ public final class ObjectModel {
|
|||||||
let description = relationshipsByName[relationship.keyPath]!
|
let description = relationshipsByName[relationship.keyPath]!
|
||||||
description.destinationEntity = entityDescriptionsByEntity[destinationEntity]!
|
description.destinationEntity = entityDescriptionsByEntity[destinationEntity]!
|
||||||
|
|
||||||
if let destinationKeyPath = destinationKeyPath {
|
if let destinationKeyPath = destinationKeyPath() {
|
||||||
|
|
||||||
let inverseRelationshipDescription = findInverseRelationshipMatching(
|
let inverseRelationshipDescription = findInverseRelationshipMatching(
|
||||||
destinationEntity: destinationEntity,
|
destinationEntity: destinationEntity,
|
||||||
@@ -284,8 +282,8 @@ public final class ObjectModel {
|
|||||||
func connectBaseEntity(mirror: Mirror, entityDescription: NSEntityDescription) {
|
func connectBaseEntity(mirror: Mirror, entityDescription: NSEntityDescription) {
|
||||||
|
|
||||||
guard let superclassMirror = mirror.superclassMirror,
|
guard let superclassMirror = mirror.superclassMirror,
|
||||||
let superType = superclassMirror.subjectType as? ManagedObject.Type,
|
let superType = superclassMirror.subjectType as? CoreStoreObject.Type,
|
||||||
superType != ManagedObject.self else {
|
superType != CoreStoreObject.self else {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -325,7 +323,7 @@ fileprivate enum ModelCache {
|
|||||||
return self.barrierQueue.cs_barrierSync(closure)
|
return self.barrierQueue.cs_barrierSync(closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate static func entityDescription(for entity: ObjectModel.AnyEntity, initializer: (ObjectModel.AnyEntity) -> NSEntityDescription) -> NSEntityDescription {
|
fileprivate static func entityDescription(for entity: DynamicModel.AnyEntity, initializer: (DynamicModel.AnyEntity) -> NSEntityDescription) -> NSEntityDescription {
|
||||||
|
|
||||||
if let cachedEntityDescription = self.entityDescriptionsByEntity[entity] {
|
if let cachedEntityDescription = self.entityDescriptionsByEntity[entity] {
|
||||||
|
|
||||||
@@ -341,5 +339,5 @@ fileprivate enum ModelCache {
|
|||||||
|
|
||||||
private static let barrierQueue = DispatchQueue.concurrent("com.coreStore.modelCacheBarrierQueue")
|
private static let barrierQueue = DispatchQueue.concurrent("com.coreStore.modelCacheBarrierQueue")
|
||||||
|
|
||||||
private static var entityDescriptionsByEntity: [ObjectModel.AnyEntity: NSEntityDescription] = [:]
|
private static var entityDescriptionsByEntity: [DynamicModel.AnyEntity: NSEntityDescription] = [:]
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// ManagedObjectProtocol.swift
|
// DynamicObject.swift
|
||||||
// CoreStore
|
// CoreStore
|
||||||
//
|
//
|
||||||
// Copyright © 2017 John Rommel Estropia
|
// Copyright © 2017 John Rommel Estropia
|
||||||
@@ -26,25 +26,27 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
// MARK: - ManagedObjectProtocol
|
// MARK: - DynamicObject
|
||||||
|
|
||||||
public protocol ManagedObjectProtocol: class {
|
public protocol DynamicObject: class {
|
||||||
|
|
||||||
static func cs_forceCreate(entityDescription: NSEntityDescription, into context: NSManagedObjectContext, assignTo store: NSPersistentStore) -> Self
|
static func cs_forceCreate(entityDescription: NSEntityDescription, into context: NSManagedObjectContext, assignTo store: NSPersistentStore) -> Self
|
||||||
|
|
||||||
static func cs_from(object: NSManagedObject) -> Self
|
static func cs_fromRaw(object: NSManagedObject) -> Self
|
||||||
|
|
||||||
|
func cs_toRaw() -> NSManagedObject
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension ManagedObjectProtocol where Self: ManagedObject {
|
public extension DynamicObject where Self: CoreStoreObject {
|
||||||
|
|
||||||
@inline(__always)
|
@inline(__always)
|
||||||
public static func keyPath<O: ManagedObject, V: ImportableAttributeType>(_ attribute: (Self) -> AttributeContainer<O>.Required<V>) -> String {
|
public static func keyPath<O: CoreStoreObject, V: ImportableAttributeType>(_ attribute: (Self) -> ValueContainer<O>.Required<V>) -> String {
|
||||||
|
|
||||||
return attribute(self.meta).keyPath
|
return attribute(self.meta).keyPath
|
||||||
}
|
}
|
||||||
|
|
||||||
@inline(__always)
|
@inline(__always)
|
||||||
public static func keyPath<O: ManagedObject, V: ImportableAttributeType>(_ attribute: (Self) -> AttributeContainer<O>.Optional<V>) -> String {
|
public static func keyPath<O: CoreStoreObject, V: ImportableAttributeType>(_ attribute: (Self) -> ValueContainer<O>.Optional<V>) -> String {
|
||||||
|
|
||||||
return attribute(self.meta).keyPath
|
return attribute(self.meta).keyPath
|
||||||
}
|
}
|
||||||
@@ -67,19 +69,9 @@ public extension ManagedObjectProtocol where Self: ManagedObject {
|
|||||||
|
|
||||||
// MARK: - NSManagedObject
|
// MARK: - NSManagedObject
|
||||||
|
|
||||||
extension NSManagedObject: ManagedObjectProtocol {
|
extension NSManagedObject: DynamicObject {
|
||||||
|
|
||||||
// MARK: ManagedObjectProtocol
|
// MARK: DynamicObject
|
||||||
|
|
||||||
public class func cs_from(object: NSManagedObject) -> Self {
|
|
||||||
|
|
||||||
@inline(__always)
|
|
||||||
func forceCast<T: NSManagedObject>(_ value: Any) -> T {
|
|
||||||
|
|
||||||
return value as! T
|
|
||||||
}
|
|
||||||
return forceCast(object)
|
|
||||||
}
|
|
||||||
|
|
||||||
public class func cs_forceCreate(entityDescription: NSEntityDescription, into context: NSManagedObjectContext, assignTo store: NSPersistentStore) -> Self {
|
public class func cs_forceCreate(entityDescription: NSEntityDescription, into context: NSManagedObjectContext, assignTo store: NSPersistentStore) -> Self {
|
||||||
|
|
||||||
@@ -90,19 +82,29 @@ extension NSManagedObject: ManagedObjectProtocol {
|
|||||||
}
|
}
|
||||||
return object
|
return object
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class func cs_fromRaw(object: NSManagedObject) -> Self {
|
||||||
|
|
||||||
|
@inline(__always)
|
||||||
|
func forceCast<T: NSManagedObject>(_ value: Any) -> T {
|
||||||
|
|
||||||
|
return value as! T
|
||||||
|
}
|
||||||
|
return forceCast(object)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func cs_toRaw() -> NSManagedObject {
|
||||||
|
|
||||||
|
return self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: - ManagedObject
|
// MARK: - CoreStoreObject
|
||||||
|
|
||||||
extension ManagedObject {
|
extension CoreStoreObject {
|
||||||
|
|
||||||
// MARK: ManagedObjectProtocol
|
// MARK: DynamicObject
|
||||||
|
|
||||||
public class func cs_from(object: NSManagedObject) -> Self {
|
|
||||||
|
|
||||||
return self.init(object)
|
|
||||||
}
|
|
||||||
|
|
||||||
public class func cs_forceCreate(entityDescription: NSEntityDescription, into context: NSManagedObjectContext, assignTo store: NSPersistentStore) -> Self {
|
public class func cs_forceCreate(entityDescription: NSEntityDescription, into context: NSManagedObjectContext, assignTo store: NSPersistentStore) -> Self {
|
||||||
|
|
||||||
@@ -114,4 +116,14 @@ extension ManagedObject {
|
|||||||
}
|
}
|
||||||
return self.init(object)
|
return self.init(object)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class func cs_fromRaw(object: NSManagedObject) -> Self {
|
||||||
|
|
||||||
|
return self.init(object)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func cs_toRaw() -> NSManagedObject {
|
||||||
|
|
||||||
|
return self.rawObject!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -32,14 +32,14 @@ import ObjectiveC
|
|||||||
|
|
||||||
public protocol EntityProtocol {
|
public protocol EntityProtocol {
|
||||||
|
|
||||||
var type: ManagedObject.Type { get }
|
var type: CoreStoreObject.Type { get }
|
||||||
var entityName: EntityName { get }
|
var entityName: EntityName { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: Entity
|
// MARK: Entity
|
||||||
|
|
||||||
public struct Entity<O: ManagedObject>: EntityProtocol {
|
public struct Entity<O: CoreStoreObject>: EntityProtocol {
|
||||||
|
|
||||||
public init(_ entityName: String) {
|
public init(_ entityName: String) {
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ public struct Entity<O: ManagedObject>: EntityProtocol {
|
|||||||
|
|
||||||
// MARK: EntityProtocol
|
// MARK: EntityProtocol
|
||||||
|
|
||||||
public let type: ManagedObject.Type
|
public let type: CoreStoreObject.Type
|
||||||
public let entityName: EntityName
|
public let entityName: EntityName
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,24 +78,24 @@ internal struct EntityIdentifier: Hashable {
|
|||||||
self.interfacedClassName = String(reflecting: type)
|
self.interfacedClassName = String(reflecting: type)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal init(_ type: ManagedObject.Type) {
|
internal init(_ type: CoreStoreObject.Type) {
|
||||||
|
|
||||||
self.category = .coreStore
|
self.category = .coreStore
|
||||||
self.interfacedClassName = String(reflecting: type)
|
self.interfacedClassName = String(reflecting: type)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal init(_ type: ManagedObjectProtocol.Type) {
|
internal init(_ type: DynamicObject.Type) {
|
||||||
|
|
||||||
switch type {
|
switch type {
|
||||||
|
|
||||||
case let type as NSManagedObject.Type:
|
case let type as NSManagedObject.Type:
|
||||||
self.init(type)
|
self.init(type)
|
||||||
|
|
||||||
case let type as ManagedObject.Type:
|
case let type as CoreStoreObject.Type:
|
||||||
self.init(type)
|
self.init(type)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
CoreStore.abort("\(cs_typeName(ManagedObjectProtocol.self)) is not meant to be implemented by external types.")
|
CoreStore.abort("\(cs_typeName(DynamicObject.self)) is not meant to be implemented by external types.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ internal struct EntityIdentifier: Hashable {
|
|||||||
internal extension NSEntityDescription {
|
internal extension NSEntityDescription {
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal var anyEntity: ObjectModel.AnyEntity? {
|
internal var anyEntity: DynamicModel.AnyEntity? {
|
||||||
|
|
||||||
get {
|
get {
|
||||||
|
|
||||||
@@ -148,8 +148,8 @@ internal extension NSEntityDescription {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return ObjectModel.AnyEntity(
|
return DynamicModel.AnyEntity(
|
||||||
type: NSClassFromString(typeName) as! ManagedObject.Type,
|
type: NSClassFromString(typeName) as! CoreStoreObject.Type,
|
||||||
entityName: entityName
|
entityName: entityName
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,14 @@ import CoreData
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
// MARK: - ManagedObjectProtocol
|
// MARK: Operators
|
||||||
|
|
||||||
public extension ManagedObjectProtocol where Self: ManagedObject {
|
infix operator .= : AssignmentPrecedence
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - DynamicObject
|
||||||
|
|
||||||
|
public extension DynamicObject where Self: CoreStoreObject {
|
||||||
|
|
||||||
public typealias Relationship = RelationshipContainer<Self>
|
public typealias Relationship = RelationshipContainer<Self>
|
||||||
}
|
}
|
||||||
@@ -37,11 +42,11 @@ public extension ManagedObjectProtocol where Self: ManagedObject {
|
|||||||
|
|
||||||
// MARK: - RelationshipContainer
|
// MARK: - RelationshipContainer
|
||||||
|
|
||||||
public enum RelationshipContainer<O: ManagedObject> {
|
public enum RelationshipContainer<O: CoreStoreObject> {
|
||||||
|
|
||||||
// MARK: - ToOne
|
// MARK: - ToOne
|
||||||
|
|
||||||
public final class ToOne<D: ManagedObject>: RelationshipProtocol {
|
public final class ToOne<D: CoreStoreObject>: RelationshipProtocol {
|
||||||
|
|
||||||
// MARK: -
|
// MARK: -
|
||||||
|
|
||||||
@@ -50,64 +55,82 @@ public enum RelationshipContainer<O: ManagedObject> {
|
|||||||
relationship.value = value
|
relationship.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
public static postfix func * (_ relationship: RelationshipContainer<O>.ToOne<D>) -> D? {
|
public static func .=<O2: CoreStoreObject> (_ relationship: RelationshipContainer<O>.ToOne<D>, _ relationship2: RelationshipContainer<O2>.ToOne<D>) {
|
||||||
|
|
||||||
return relationship.value
|
relationship.value = relationship2.value
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(_ keyPath: String, deleteRule: DeleteRule = .nullify) {
|
public convenience init(_ keyPath: KeyPath, deleteRule: DeleteRule = .nullify) {
|
||||||
|
|
||||||
self.keyPath = keyPath
|
self.init(keyPath: keyPath, inverseKeyPath: { nil }, deleteRule: deleteRule)
|
||||||
self.deleteRule = deleteRule.nativeValue
|
|
||||||
self.inverse = (D.self, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(_ keyPath: String, inverse: (D) -> RelationshipContainer<D>.ToOne<O>, deleteRule: DeleteRule = .nullify) {
|
public convenience init(_ keyPath: KeyPath, inverse: @escaping (D) -> RelationshipContainer<D>.ToOne<O>, deleteRule: DeleteRule = .nullify) {
|
||||||
|
|
||||||
self.keyPath = keyPath
|
self.init(keyPath: keyPath, inverseKeyPath: { inverse(D.meta).keyPath }, deleteRule: deleteRule)
|
||||||
self.deleteRule = deleteRule.nativeValue
|
}
|
||||||
|
|
||||||
let inverseRelationship = inverse(D.meta)
|
public convenience init(_ keyPath: KeyPath, inverse: @escaping (D) -> RelationshipContainer<D>.ToManyOrdered<O>, deleteRule: DeleteRule = .nullify) {
|
||||||
self.inverse = (D.self, inverseRelationship.keyPath)
|
|
||||||
|
self.init(keyPath: keyPath, inverseKeyPath: { inverse(D.meta).keyPath }, deleteRule: deleteRule)
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init(_ keyPath: KeyPath, inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>, deleteRule: DeleteRule = .nullify) {
|
||||||
|
|
||||||
|
self.init(keyPath: keyPath, inverseKeyPath: { inverse(D.meta).keyPath }, deleteRule: deleteRule)
|
||||||
}
|
}
|
||||||
|
|
||||||
public var value: D? {
|
public var value: D? {
|
||||||
|
|
||||||
get {
|
get {
|
||||||
|
|
||||||
let object = self.accessRawObject()
|
return self.accessRawObject()
|
||||||
let key = self.keyPath
|
.getValue(
|
||||||
return object.value(forKey: key)
|
forKvcKey: self.keyPath,
|
||||||
.flatMap({ D.cs_from(object: $0 as! NSManagedObject) })
|
didGetValue: { $0.flatMap({ D.cs_fromRaw(object: $0 as! NSManagedObject) }) }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
|
||||||
let object = self.accessRawObject()
|
self.accessRawObject()
|
||||||
let key = self.keyPath
|
.setValue(
|
||||||
object.setValue(newValue?.rawObject, forKey: key)
|
newValue,
|
||||||
|
forKvcKey: self.keyPath,
|
||||||
|
willSetValue: { $0?.rawObject }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: RelationshipProtocol
|
// MARK: RelationshipProtocol
|
||||||
|
|
||||||
public let keyPath: String
|
public let keyPath: KeyPath
|
||||||
|
|
||||||
internal let isToMany = false
|
internal let isToMany = false
|
||||||
internal let isOrdered = false
|
internal let isOrdered = false
|
||||||
internal let deleteRule: NSDeleteRule
|
internal let deleteRule: NSDeleteRule
|
||||||
internal let inverse: (type: ManagedObject.Type, keyPath: String?)
|
internal let inverse: (type: CoreStoreObject.Type, keyPath: () -> KeyPath?)
|
||||||
|
|
||||||
internal var accessRawObject: () -> NSManagedObject = {
|
internal var accessRawObject: () -> NSManagedObject = {
|
||||||
|
|
||||||
fatalError("\(O.self) relationship values should not be accessed")
|
CoreStore.abort("Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types.")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: Private
|
||||||
|
|
||||||
|
private init(keyPath: KeyPath, inverseKeyPath: @escaping () -> KeyPath?, deleteRule: DeleteRule) {
|
||||||
|
|
||||||
|
self.keyPath = keyPath
|
||||||
|
self.deleteRule = deleteRule.nativeValue
|
||||||
|
self.inverse = (D.self, inverseKeyPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: - ToManyOrdered
|
// MARK: - ToManyOrdered
|
||||||
|
|
||||||
public final class ToManyOrdered<D: ManagedObject>: RelationshipProtocol {
|
public final class ToManyOrdered<D: CoreStoreObject>: RelationshipProtocol {
|
||||||
|
|
||||||
// MARK: -
|
// MARK: -
|
||||||
|
|
||||||
@@ -116,52 +139,194 @@ public enum RelationshipContainer<O: ManagedObject> {
|
|||||||
relationship.value = value
|
relationship.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
public static postfix func * (_ relationship: RelationshipContainer<O>.ToManyOrdered<D>) -> [D] {
|
public static func .=<C: Collection> (_ relationship: RelationshipContainer<O>.ToManyOrdered<D>, _ value: C) where C.Iterator.Element == D {
|
||||||
|
|
||||||
return relationship.value
|
relationship.value = Array(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(_ keyPath: String, deleteRule: DeleteRule = .nullify) {
|
public static func .=<O2: CoreStoreObject> (_ relationship: RelationshipContainer<O>.ToManyOrdered<D>, _ relationship2: RelationshipContainer<O2>.ToManyOrdered<D>) {
|
||||||
|
|
||||||
self.keyPath = keyPath
|
relationship.value = relationship2.value
|
||||||
self.deleteRule = deleteRule.nativeValue
|
|
||||||
self.inverse = (D.self, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public convenience init(_ keyPath: KeyPath, deleteRule: DeleteRule = .nullify) {
|
||||||
|
|
||||||
|
self.init(keyPath: keyPath, inverseKeyPath: { nil }, deleteRule: deleteRule)
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init(_ keyPath: KeyPath, inverse: @escaping (D) -> RelationshipContainer<D>.ToOne<O>, deleteRule: DeleteRule = .nullify) {
|
||||||
|
|
||||||
|
self.init(keyPath: keyPath, inverseKeyPath: { inverse(D.meta).keyPath }, deleteRule: deleteRule)
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init(_ keyPath: KeyPath, inverse: @escaping (D) -> RelationshipContainer<D>.ToManyOrdered<O>, deleteRule: DeleteRule = .nullify) {
|
||||||
|
|
||||||
|
self.init(keyPath: keyPath, inverseKeyPath: { inverse(D.meta).keyPath }, deleteRule: deleteRule)
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init(_ keyPath: KeyPath, inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>, deleteRule: DeleteRule = .nullify) {
|
||||||
|
|
||||||
|
self.init(keyPath: keyPath, inverseKeyPath: { inverse(D.meta).keyPath }, deleteRule: deleteRule)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: add subscripts, indexed operations for more performant single updates
|
||||||
|
|
||||||
public var value: [D] {
|
public var value: [D] {
|
||||||
|
|
||||||
get {
|
get {
|
||||||
|
|
||||||
let object = self.accessRawObject()
|
return self.accessRawObject()
|
||||||
let key = self.keyPath
|
.getValue(
|
||||||
guard let orderedSet = object.value(forKey: key) as! NSOrderedSet? else {
|
forKvcKey: self.keyPath,
|
||||||
|
didGetValue: {
|
||||||
|
|
||||||
return []
|
guard let orderedSet = $0 as! NSOrderedSet? else {
|
||||||
}
|
|
||||||
return orderedSet.array as! [D]
|
return []
|
||||||
|
}
|
||||||
|
return orderedSet.map({ D.cs_fromRaw(object: $0 as! NSManagedObject) })
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
|
||||||
let object = self.accessRawObject()
|
self.accessRawObject()
|
||||||
let key = self.keyPath
|
.setValue(
|
||||||
object.setValue(NSOrderedSet(array: newValue), forKey: key)
|
newValue,
|
||||||
|
forKvcKey: self.keyPath,
|
||||||
|
willSetValue: { NSOrderedSet(array: $0.map({ $0.rawObject! })) }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: RelationshipProtocol
|
// MARK: RelationshipProtocol
|
||||||
|
|
||||||
public let keyPath: String
|
public let keyPath: KeyPath
|
||||||
|
|
||||||
internal let isToMany = true
|
internal let isToMany = true
|
||||||
internal let isOptional = true
|
internal let isOptional = true
|
||||||
internal let isOrdered = true
|
internal let isOrdered = true
|
||||||
internal let deleteRule: NSDeleteRule
|
internal let deleteRule: NSDeleteRule
|
||||||
internal let inverse: (type: ManagedObject.Type, keyPath: String?)
|
internal let inverse: (type: CoreStoreObject.Type, keyPath: () -> KeyPath?)
|
||||||
|
|
||||||
internal var accessRawObject: () -> NSManagedObject = {
|
internal var accessRawObject: () -> NSManagedObject = {
|
||||||
|
|
||||||
fatalError("\(O.self) relationship values should not be accessed")
|
CoreStore.abort("Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types.")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: Private
|
||||||
|
|
||||||
|
private init(keyPath: String, inverseKeyPath: @escaping () -> String?, deleteRule: DeleteRule) {
|
||||||
|
|
||||||
|
self.keyPath = keyPath
|
||||||
|
self.deleteRule = deleteRule.nativeValue
|
||||||
|
self.inverse = (D.self, inverseKeyPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - ToManyUnordered
|
||||||
|
|
||||||
|
public final class ToManyUnordered<D: CoreStoreObject>: RelationshipProtocol {
|
||||||
|
|
||||||
|
// MARK: -
|
||||||
|
|
||||||
|
public static func .= (_ relationship: RelationshipContainer<O>.ToManyUnordered<D>, _ value: Set<D>) {
|
||||||
|
|
||||||
|
relationship.value = value
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func .=<C: Collection> (_ relationship: RelationshipContainer<O>.ToManyUnordered<D>, _ value: C) where C.Iterator.Element == D {
|
||||||
|
|
||||||
|
relationship.value = Set(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func .=<O2: CoreStoreObject> (_ relationship: RelationshipContainer<O>.ToManyUnordered<D>, _ relationship2: RelationshipContainer<O2>.ToManyUnordered<D>) {
|
||||||
|
|
||||||
|
relationship.value = relationship2.value
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func .=<O2: CoreStoreObject> (_ relationship: RelationshipContainer<O>.ToManyUnordered<D>, _ relationship2: RelationshipContainer<O2>.ToManyOrdered<D>) {
|
||||||
|
|
||||||
|
relationship.value = Set(relationship2.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init(_ keyPath: KeyPath, deleteRule: DeleteRule = .nullify) {
|
||||||
|
|
||||||
|
self.init(keyPath: keyPath, inverseKeyPath: { nil }, deleteRule: deleteRule)
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init(_ keyPath: KeyPath, inverse: @escaping (D) -> RelationshipContainer<D>.ToOne<O>, deleteRule: DeleteRule = .nullify) {
|
||||||
|
|
||||||
|
self.init(keyPath: keyPath, inverseKeyPath: { inverse(D.meta).keyPath }, deleteRule: deleteRule)
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init(_ keyPath: KeyPath, inverse: @escaping (D) -> RelationshipContainer<D>.ToManyOrdered<O>, deleteRule: DeleteRule = .nullify) {
|
||||||
|
|
||||||
|
self.init(keyPath: keyPath, inverseKeyPath: { inverse(D.meta).keyPath }, deleteRule: deleteRule)
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init(_ keyPath: KeyPath, inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>, deleteRule: DeleteRule = .nullify) {
|
||||||
|
|
||||||
|
self.init(keyPath: keyPath, inverseKeyPath: { inverse(D.meta).keyPath }, deleteRule: deleteRule)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: add subscripts, indexed operations for more performant single updates
|
||||||
|
|
||||||
|
public var value: Set<D> {
|
||||||
|
|
||||||
|
get {
|
||||||
|
|
||||||
|
return self.accessRawObject()
|
||||||
|
.getValue(
|
||||||
|
forKvcKey: self.keyPath,
|
||||||
|
didGetValue: {
|
||||||
|
|
||||||
|
guard let set = $0 as! NSSet? else {
|
||||||
|
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return Set(set.map({ D.cs_fromRaw(object: $0 as! NSManagedObject) }))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
|
||||||
|
self.accessRawObject()
|
||||||
|
.setValue(
|
||||||
|
newValue,
|
||||||
|
forKvcKey: self.keyPath,
|
||||||
|
willSetValue: { NSSet(array: $0.map({ $0.rawObject! })) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: RelationshipProtocol
|
||||||
|
|
||||||
|
public let keyPath: KeyPath
|
||||||
|
|
||||||
|
internal let isToMany = true
|
||||||
|
internal let isOptional = true
|
||||||
|
internal let isOrdered = true
|
||||||
|
internal let deleteRule: NSDeleteRule
|
||||||
|
internal let inverse: (type: CoreStoreObject.Type, keyPath: () -> KeyPath?)
|
||||||
|
|
||||||
|
internal var accessRawObject: () -> NSManagedObject = {
|
||||||
|
|
||||||
|
CoreStore.abort("Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types.")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: Private
|
||||||
|
|
||||||
|
private init(keyPath: KeyPath, inverseKeyPath: @escaping () -> KeyPath?, deleteRule: DeleteRule) {
|
||||||
|
|
||||||
|
self.keyPath = keyPath
|
||||||
|
self.deleteRule = deleteRule.nativeValue
|
||||||
|
self.inverse = (D.self, inverseKeyPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,10 +356,10 @@ public enum RelationshipContainer<O: ManagedObject> {
|
|||||||
|
|
||||||
internal protocol RelationshipProtocol: class {
|
internal protocol RelationshipProtocol: class {
|
||||||
|
|
||||||
var keyPath: String { get }
|
var keyPath: KeyPath { get }
|
||||||
var isToMany: Bool { get }
|
var isToMany: Bool { get }
|
||||||
var isOrdered: Bool { get }
|
var isOrdered: Bool { get }
|
||||||
var deleteRule: NSDeleteRule { get }
|
var deleteRule: NSDeleteRule { get }
|
||||||
var inverse: (type: ManagedObject.Type, keyPath: String?) { get }
|
var inverse: (type: CoreStoreObject.Type, keyPath: () -> KeyPath?) { get }
|
||||||
var accessRawObject: () -> NSManagedObject { get set }
|
var accessRawObject: () -> NSManagedObject { get set }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// Attribute.swift
|
// Value.swift
|
||||||
// CoreStore
|
// CoreStore
|
||||||
//
|
//
|
||||||
// Copyright © 2017 John Rommel Estropia
|
// Copyright © 2017 John Rommel Estropia
|
||||||
@@ -30,56 +30,60 @@ import Foundation
|
|||||||
// MARK: Operators
|
// MARK: Operators
|
||||||
|
|
||||||
infix operator .= : AssignmentPrecedence
|
infix operator .= : AssignmentPrecedence
|
||||||
postfix operator *
|
|
||||||
|
|
||||||
|
|
||||||
// MARK: - ManagedObjectProtocol
|
// MARK: - DynamicObject
|
||||||
|
|
||||||
public extension ManagedObjectProtocol where Self: ManagedObject {
|
public extension DynamicObject where Self: CoreStoreObject {
|
||||||
|
|
||||||
public typealias Attribute = AttributeContainer<Self>
|
public typealias Value = ValueContainer<Self>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: - AttributeContainer
|
// MARK: - ValueContainer
|
||||||
|
|
||||||
public enum AttributeContainer<O: ManagedObject> {
|
public enum ValueContainer<O: CoreStoreObject> {
|
||||||
|
|
||||||
// MARK: - Required
|
// MARK: - Required
|
||||||
|
|
||||||
public final class Required<V: ImportableAttributeType>: AttributeProtocol {
|
public final class Required<V: ImportableAttributeType>: AttributeProtocol {
|
||||||
|
|
||||||
public static func .= (_ attribute: AttributeContainer<O>.Required<V>, _ value: V) {
|
public static func .= (_ attribute: ValueContainer<O>.Required<V>, _ value: V) {
|
||||||
|
|
||||||
attribute.value = value
|
attribute.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
public static postfix func * (_ attribute: AttributeContainer<O>.Required<V>) -> V {
|
public static func .=<O2: CoreStoreObject> (_ attribute: ValueContainer<O>.Required<V>, _ attribute2: ValueContainer<O2>.Required<V>) {
|
||||||
|
|
||||||
return attribute.value
|
attribute.value = attribute2.value
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(_ keyPath: String, `default`: V = V.cs_emptyValue(), isIndexed: Bool = false) {
|
public init(_ keyPath: KeyPath, `default`: V = V.cs_emptyValue(), isIndexed: Bool = false, isTransient: Bool = false) {
|
||||||
|
|
||||||
self.keyPath = keyPath
|
self.keyPath = keyPath
|
||||||
self.defaultValue = `default`.cs_toImportableNativeType()
|
|
||||||
self.isIndexed = isIndexed
|
self.isIndexed = isIndexed
|
||||||
|
self.isTransient = isTransient
|
||||||
|
self.defaultValue = `default`.cs_toImportableNativeType()
|
||||||
}
|
}
|
||||||
|
|
||||||
public var value: V {
|
public var value: V {
|
||||||
|
|
||||||
get {
|
get {
|
||||||
|
|
||||||
let object = self.accessRawObject()
|
return self.accessRawObject()
|
||||||
let key = self.keyPath
|
.getValue(
|
||||||
let value = object.value(forKey: key)! as! V.ImportableNativeType
|
forKvcKey: self.keyPath,
|
||||||
return V.cs_fromImportableNativeType(value)!
|
didGetValue: { V.cs_fromImportableNativeType($0 as! V.ImportableNativeType)! }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
|
||||||
let object = self.accessRawObject()
|
self.accessRawObject()
|
||||||
let key = self.keyPath
|
.setValue(
|
||||||
object.setValue(newValue.cs_toImportableNativeType(), forKey: key)
|
newValue,
|
||||||
|
forKvcKey: self.keyPath,
|
||||||
|
willSetValue: { $0.cs_toImportableNativeType() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,15 +95,16 @@ public enum AttributeContainer<O: ManagedObject> {
|
|||||||
return V.cs_rawAttributeType
|
return V.cs_rawAttributeType
|
||||||
}
|
}
|
||||||
|
|
||||||
public let keyPath: String
|
public let keyPath: KeyPath
|
||||||
|
|
||||||
internal let isOptional = false
|
internal let isOptional = false
|
||||||
internal let isIndexed: Bool
|
internal let isIndexed: Bool
|
||||||
|
internal let isTransient: Bool
|
||||||
internal let defaultValue: Any?
|
internal let defaultValue: Any?
|
||||||
|
|
||||||
internal var accessRawObject: () -> NSManagedObject = {
|
internal var accessRawObject: () -> NSManagedObject = {
|
||||||
|
|
||||||
fatalError("\(O.self) attribute values should not be accessed")
|
CoreStore.abort("Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,19 +113,25 @@ public enum AttributeContainer<O: ManagedObject> {
|
|||||||
|
|
||||||
public final class Optional<V: ImportableAttributeType>: AttributeProtocol {
|
public final class Optional<V: ImportableAttributeType>: AttributeProtocol {
|
||||||
|
|
||||||
public static func .= (_ attribute: AttributeContainer<O>.Optional<V>, _ value: V?) {
|
public static func .= (_ attribute: ValueContainer<O>.Optional<V>, _ value: V?) {
|
||||||
|
|
||||||
attribute.value = value
|
attribute.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
public static postfix func * (_ attribute: AttributeContainer<O>.Optional<V>) -> V? {
|
public static func .=<O2: CoreStoreObject> (_ attribute: ValueContainer<O>.Optional<V>, _ attribute2: ValueContainer<O2>.Optional<V>) {
|
||||||
|
|
||||||
return attribute.value
|
attribute.value = attribute2.value
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(_ keyPath: String, `default`: V? = nil) {
|
public static func .=<O2: CoreStoreObject> (_ attribute: ValueContainer<O>.Optional<V>, _ attribute2: ValueContainer<O2>.Required<V>) {
|
||||||
|
|
||||||
|
attribute.value = attribute2.value
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(_ keyPath: KeyPath, `default`: V? = nil, isTransient: Bool = false) {
|
||||||
|
|
||||||
self.keyPath = keyPath
|
self.keyPath = keyPath
|
||||||
|
self.isTransient = isTransient
|
||||||
self.defaultValue = `default`?.cs_toImportableNativeType()
|
self.defaultValue = `default`?.cs_toImportableNativeType()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,19 +139,20 @@ public enum AttributeContainer<O: ManagedObject> {
|
|||||||
|
|
||||||
get {
|
get {
|
||||||
|
|
||||||
let object = self.accessRawObject()
|
return self.accessRawObject()
|
||||||
let key = self.keyPath
|
.getValue(
|
||||||
guard let value = object.value(forKey: key) as! V.ImportableNativeType? else {
|
forKvcKey: self.keyPath,
|
||||||
|
didGetValue: { ($0 as! V.ImportableNativeType?).flatMap(V.cs_fromImportableNativeType) }
|
||||||
return nil
|
)
|
||||||
}
|
|
||||||
return V.cs_fromImportableNativeType(value)
|
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
|
||||||
let object = self.accessRawObject()
|
self.accessRawObject()
|
||||||
let key = self.keyPath
|
.setValue(
|
||||||
object.setValue(newValue?.cs_toImportableNativeType(), forKey: key)
|
newValue,
|
||||||
|
forKvcKey: self.keyPath,
|
||||||
|
willSetValue: { $0?.cs_toImportableNativeType() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,14 +164,15 @@ public enum AttributeContainer<O: ManagedObject> {
|
|||||||
return V.cs_rawAttributeType
|
return V.cs_rawAttributeType
|
||||||
}
|
}
|
||||||
|
|
||||||
public let keyPath: String
|
public let keyPath: KeyPath
|
||||||
internal let isOptional = true
|
internal let isOptional = true
|
||||||
internal let isIndexed = false
|
internal let isIndexed = false
|
||||||
|
internal let isTransient: Bool
|
||||||
internal let defaultValue: Any?
|
internal let defaultValue: Any?
|
||||||
|
|
||||||
internal var accessRawObject: () -> NSManagedObject = {
|
internal var accessRawObject: () -> NSManagedObject = {
|
||||||
|
|
||||||
fatalError("\(O.self) attribute values should not be accessed")
|
CoreStore.abort("Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,9 +184,10 @@ internal protocol AttributeProtocol: class {
|
|||||||
|
|
||||||
static var attributeType: NSAttributeType { get }
|
static var attributeType: NSAttributeType { get }
|
||||||
|
|
||||||
var keyPath: String { get }
|
var keyPath: KeyPath { get }
|
||||||
var isOptional: Bool { get }
|
var isOptional: Bool { get }
|
||||||
var isIndexed: Bool { get }
|
var isIndexed: Bool { get }
|
||||||
|
var isTransient: Bool { get }
|
||||||
var defaultValue: Any? { get }
|
var defaultValue: Any? { get }
|
||||||
var accessRawObject: () -> NSManagedObject { get set }
|
var accessRawObject: () -> NSManagedObject { get set }
|
||||||
}
|
}
|
||||||
@@ -83,12 +83,12 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
|
|||||||
// MARK: BaseDataTransaction
|
// MARK: BaseDataTransaction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a new `NSManagedObject` or `ManagedObject` with the specified entity type.
|
Creates a new `NSManagedObject` or `CoreStoreObject` with the specified entity type.
|
||||||
|
|
||||||
- parameter into: the `Into` clause indicating the destination `NSManagedObject` or `ManagedObject` entity type and the destination configuration
|
- parameter into: the `Into` clause indicating the destination `NSManagedObject` or `CoreStoreObject` entity type and the destination configuration
|
||||||
- returns: a new `NSManagedObject` or `ManagedObject` instance of the specified entity type.
|
- returns: a new `NSManagedObject` or `CoreStoreObject` instance of the specified entity type.
|
||||||
*/
|
*/
|
||||||
public override func create<T: ManagedObjectProtocol>(_ into: Into<T>) -> T {
|
public override func create<T: DynamicObject>(_ into: Into<T>) -> T {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
@@ -136,7 +136,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
|
|||||||
|
|
||||||
- parameter object: the `NSManagedObject` type to be deleted
|
- parameter object: the `NSManagedObject` type to be deleted
|
||||||
*/
|
*/
|
||||||
public override func delete(_ object: NSManagedObject?) {
|
public override func delete<T: DynamicObject>(_ object: T?) {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
@@ -153,7 +153,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
|
|||||||
- parameter object2: another `NSManagedObject` type to be deleted
|
- parameter object2: another `NSManagedObject` type to be deleted
|
||||||
- parameter objects: other `NSManagedObject`s type to be deleted
|
- parameter objects: other `NSManagedObject`s type to be deleted
|
||||||
*/
|
*/
|
||||||
public override func delete(_ object1: NSManagedObject?, _ object2: NSManagedObject?, _ objects: NSManagedObject?...) {
|
public override func delete<T: DynamicObject>(_ object1: T?, _ object2: T?, _ objects: T?...) {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
|
|||||||
@@ -45,12 +45,12 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a new `NSManagedObject` or `ManagedObject` with the specified entity type.
|
Creates a new `NSManagedObject` or `CoreStoreObject` with the specified entity type.
|
||||||
|
|
||||||
- parameter into: the `Into` clause indicating the destination `NSManagedObject` or `ManagedObject` entity type and the destination configuration
|
- parameter into: the `Into` clause indicating the destination `NSManagedObject` or `CoreStoreObject` entity type and the destination configuration
|
||||||
- returns: a new `NSManagedObject` or `ManagedObject` instance of the specified entity type.
|
- returns: a new `NSManagedObject` or `CoreStoreObject` instance of the specified entity type.
|
||||||
*/
|
*/
|
||||||
public func create<T: ManagedObjectProtocol>(_ into: Into<T>) -> T {
|
public func create<T: DynamicObject>(_ into: Into<T>) -> T {
|
||||||
|
|
||||||
let entityClass = into.entityClass
|
let entityClass = into.entityClass
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
@@ -121,7 +121,7 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
- parameter object: the `NSManagedObject` type to be edited
|
- parameter object: the `NSManagedObject` type to be edited
|
||||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||||
*/
|
*/
|
||||||
public func edit<T: NSManagedObject>(_ object: T?) -> T? {
|
public func edit<T: DynamicObject>(_ object: T?) -> T? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -141,7 +141,7 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
- parameter objectID: the `NSManagedObjectID` for the object to be edited
|
- parameter objectID: the `NSManagedObjectID` for the object to be edited
|
||||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||||
*/
|
*/
|
||||||
public func edit<T: NSManagedObject>(_ into: Into<T>, _ objectID: NSManagedObjectID) -> T? {
|
public func edit<T: DynamicObject>(_ into: Into<T>, _ objectID: NSManagedObjectID) -> T? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -152,7 +152,7 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
|| (into.configuration ?? DataStack.defaultConfigurationName) == objectID.persistentStore?.configurationName,
|
|| (into.configuration ?? DataStack.defaultConfigurationName) == objectID.persistentStore?.configurationName,
|
||||||
"Attempted to update an entity of type \(cs_typeName(into.entityClass)) but the specified persistent store do not match the `NSManagedObjectID`."
|
"Attempted to update an entity of type \(cs_typeName(into.entityClass)) but the specified persistent store do not match the `NSManagedObjectID`."
|
||||||
)
|
)
|
||||||
return self.fetchExisting(objectID) as? T
|
return self.fetchExisting(objectID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,7 +160,7 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
|
|
||||||
- parameter object: the `NSManagedObject` to be deleted
|
- parameter object: the `NSManagedObject` to be deleted
|
||||||
*/
|
*/
|
||||||
public func delete(_ object: NSManagedObject?) {
|
public func delete<T: DynamicObject>(_ object: T?) {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
@@ -169,7 +169,7 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
let context = self.context
|
let context = self.context
|
||||||
object
|
object
|
||||||
.flatMap(context.fetchExisting)
|
.flatMap(context.fetchExisting)
|
||||||
.flatMap(context.delete)
|
.flatMap({ context.delete($0.cs_toRaw()) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,7 +179,7 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
- parameter object2: another `NSManagedObject` to be deleted
|
- parameter object2: another `NSManagedObject` to be deleted
|
||||||
- parameter objects: other `NSManagedObject`s to be deleted
|
- parameter objects: other `NSManagedObject`s to be deleted
|
||||||
*/
|
*/
|
||||||
public func delete(_ object1: NSManagedObject?, _ object2: NSManagedObject?, _ objects: NSManagedObject?...) {
|
public func delete<T: DynamicObject>(_ object1: T?, _ object2: T?, _ objects: T?...) {
|
||||||
|
|
||||||
self.delete(([object1, object2] + objects).flatMap { $0 })
|
self.delete(([object1, object2] + objects).flatMap { $0 })
|
||||||
}
|
}
|
||||||
@@ -189,15 +189,14 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
|
|
||||||
- parameter objects: the `NSManagedObject`s to be deleted
|
- parameter objects: the `NSManagedObject`s to be deleted
|
||||||
*/
|
*/
|
||||||
public func delete<S: Sequence>(_ objects: S) where S.Iterator.Element: NSManagedObject {
|
public func delete<S: Sequence>(_ objects: S) where S.Iterator.Element: DynamicObject {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
"Attempted to delete entities outside their designated queue."
|
"Attempted to delete entities outside their designated queue."
|
||||||
)
|
)
|
||||||
|
|
||||||
let context = self.context
|
let context = self.context
|
||||||
objects.forEach { context.fetchExisting($0).flatMap(context.delete) }
|
objects.forEach { context.fetchExisting($0).flatMap({ context.delete($0.cs_toRaw()) }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,7 +208,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
self.isRunningInAllowedQueue(),
|
self.isRunningInAllowedQueue(),
|
||||||
"Attempted to refresh entities outside their designated queue."
|
"Attempted to refresh entities outside their designated queue."
|
||||||
)
|
)
|
||||||
|
|
||||||
self.context.refreshAndMergeAllObjects()
|
self.context.refreshAndMergeAllObjects()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +229,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access inserted objects from an already committed \(cs_typeName(self))."
|
"Attempted to access inserted objects from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.context.insertedObjects
|
return self.context.insertedObjects
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +248,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access inserted objects from an already committed \(cs_typeName(self))."
|
"Attempted to access inserted objects from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return Set(self.context.insertedObjects.flatMap { $0 as? T })
|
return Set(self.context.insertedObjects.flatMap { $0 as? T })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +266,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access inserted objects IDs from an already committed \(cs_typeName(self))."
|
"Attempted to access inserted objects IDs from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return Set(self.context.insertedObjects.map { $0.objectID })
|
return Set(self.context.insertedObjects.map { $0.objectID })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +285,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access inserted objects IDs from an already committed \(cs_typeName(self))."
|
"Attempted to access inserted objects IDs from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return Set(self.context.insertedObjects.filter { $0.isKind(of: entity) }.map { $0.objectID })
|
return Set(self.context.insertedObjects.filter { $0.isKind(of: entity) }.map { $0.objectID })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +303,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access updated objects from an already committed \(cs_typeName(self))."
|
"Attempted to access updated objects from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.context.updatedObjects
|
return self.context.updatedObjects
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +322,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access updated objects from an already committed \(cs_typeName(self))."
|
"Attempted to access updated objects from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return Set(self.context.updatedObjects.filter { $0.isKind(of: entity) }.map { $0 as! T })
|
return Set(self.context.updatedObjects.filter { $0.isKind(of: entity) }.map { $0 as! T })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +340,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access updated object IDs from an already committed \(cs_typeName(self))."
|
"Attempted to access updated object IDs from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return Set(self.context.updatedObjects.map { $0.objectID })
|
return Set(self.context.updatedObjects.map { $0.objectID })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,7 +359,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access updated object IDs from an already committed \(cs_typeName(self))."
|
"Attempted to access updated object IDs from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return Set(self.context.updatedObjects.filter { $0.isKind(of: entity) }.map { $0.objectID })
|
return Set(self.context.updatedObjects.filter { $0.isKind(of: entity) }.map { $0.objectID })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +377,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access deleted objects from an already committed \(cs_typeName(self))."
|
"Attempted to access deleted objects from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.context.deletedObjects
|
return self.context.deletedObjects
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,7 +396,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access deleted objects from an already committed \(cs_typeName(self))."
|
"Attempted to access deleted objects from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return Set(self.context.deletedObjects.filter { $0.isKind(of: entity) }.map { $0 as! T })
|
return Set(self.context.deletedObjects.filter { $0.isKind(of: entity) }.map { $0 as! T })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,7 +415,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access deleted object IDs from an already committed \(cs_typeName(self))."
|
"Attempted to access deleted object IDs from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return Set(self.context.deletedObjects.map { $0.objectID })
|
return Set(self.context.deletedObjects.map { $0.objectID })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,7 +434,6 @@ public /*abstract*/ class BaseDataTransaction {
|
|||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
"Attempted to access deleted object IDs from an already committed \(cs_typeName(self))."
|
"Attempted to access deleted object IDs from an already committed \(cs_typeName(self))."
|
||||||
)
|
)
|
||||||
|
|
||||||
return Set(self.context.deletedObjects.filter { $0.isKind(of: entity) }.map { $0.objectID })
|
return Set(self.context.deletedObjects.filter { $0.isKind(of: entity) }.map { $0.objectID })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ import CoreData
|
|||||||
let person = transaction.create(Into<MyPersonEntity>("Configuration1"))
|
let person = transaction.create(Into<MyPersonEntity>("Configuration1"))
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
public struct Into<T: ManagedObjectProtocol>: Hashable {
|
public struct Into<T: DynamicObject>: Hashable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The associated `NSManagedObject` or `ManagedObject` entity class
|
The associated `NSManagedObject` or `CoreStoreObject` entity class
|
||||||
*/
|
*/
|
||||||
public let entityClass: T.Type
|
public let entityClass: T.Type
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ public struct Into<T: ManagedObjectProtocol>: Hashable {
|
|||||||
|
|
||||||
// MARK: Equatable
|
// MARK: Equatable
|
||||||
|
|
||||||
public static func == <U: ManagedObjectProtocol, V: ManagedObjectProtocol>(lhs: Into<U>, rhs: Into<V>) -> Bool {
|
public static func == <U: DynamicObject, V: DynamicObject>(lhs: Into<U>, rhs: Into<V>) -> Bool {
|
||||||
|
|
||||||
return lhs.entityClass == rhs.entityClass
|
return lhs.entityClass == rhs.entityClass
|
||||||
&& lhs.configuration == rhs.configuration
|
&& lhs.configuration == rhs.configuration
|
||||||
|
|||||||
@@ -50,12 +50,12 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
|||||||
// MARK: BaseDataTransaction
|
// MARK: BaseDataTransaction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a new `NSManagedObject` or `ManagedObject` with the specified entity type.
|
Creates a new `NSManagedObject` or `CoreStoreObject` with the specified entity type.
|
||||||
|
|
||||||
- parameter into: the `Into` clause indicating the destination `NSManagedObject` or `ManagedObject` entity type and the destination configuration
|
- parameter into: the `Into` clause indicating the destination `NSManagedObject` or `CoreStoreObject` entity type and the destination configuration
|
||||||
- returns: a new `NSManagedObject` or `ManagedObject` instance of the specified entity type.
|
- returns: a new `NSManagedObject` or `CoreStoreObject` instance of the specified entity type.
|
||||||
*/
|
*/
|
||||||
public override func create<T: ManagedObjectProtocol>(_ into: Into<T>) -> T {
|
public override func create<T: DynamicObject>(_ into: Into<T>) -> T {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
@@ -103,7 +103,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
|||||||
|
|
||||||
- parameter object: the `NSManagedObject` type to be deleted
|
- parameter object: the `NSManagedObject` type to be deleted
|
||||||
*/
|
*/
|
||||||
public override func delete(_ object: NSManagedObject?) {
|
public override func delete<T: DynamicObject>(_ object: T?) {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
@@ -120,7 +120,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
|||||||
- parameter object2: another `NSManagedObject` to be deleted
|
- parameter object2: another `NSManagedObject` to be deleted
|
||||||
- parameter objects: other `NSManagedObject`s to be deleted
|
- parameter objects: other `NSManagedObject`s to be deleted
|
||||||
*/
|
*/
|
||||||
public override func delete(_ object1: NSManagedObject?, _ object2: NSManagedObject?, _ objects: NSManagedObject?...) {
|
public override func delete<T: DynamicObject>(_ object1: T?, _ object2: T?, _ objects: T?...) {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
@@ -135,7 +135,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
|||||||
|
|
||||||
- parameter objects: the `NSManagedObject`s to be deleted
|
- parameter objects: the `NSManagedObject`s to be deleted
|
||||||
*/
|
*/
|
||||||
public override func delete<S: Sequence>(_ objects: S) where S.Iterator.Element: NSManagedObject {
|
public override func delete<S: Sequence>(_ objects: S) where S.Iterator.Element: DynamicObject {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isCommitted,
|
!self.isCommitted,
|
||||||
|
|||||||
Reference in New Issue
Block a user