From b0e2655bdfe5b5d81356b2411f59fc0de1fc0a11 Mon Sep 17 00:00:00 2001 From: John Estropia Date: Wed, 19 Apr 2017 17:04:34 +0900 Subject: [PATCH] added a typealias for the object type contained in ListMonitor and ObjectMonitor --- .../BaseDataTransaction+Importing.swift | 20 +++++++++---------- Sources/Observing/ListMonitor.swift | 5 +++++ Sources/Observing/ObjectMonitor.swift | 5 +++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Sources/Importing/BaseDataTransaction+Importing.swift b/Sources/Importing/BaseDataTransaction+Importing.swift index d368f9c..d76abc4 100644 --- a/Sources/Importing/BaseDataTransaction+Importing.swift +++ b/Sources/Importing/BaseDataTransaction+Importing.swift @@ -39,9 +39,9 @@ public extension BaseDataTransaction { - throws: an `Error` thrown from any of the `ImportableObject` methods - returns: the created `ImportableObject` instance, or `nil` if the import was ignored */ - public func importObject( + public func importObject( _ into: Into, - source: T.ImportSource) throws -> T? where T: DynamicObject, T: ImportableObject { + source: T.ImportSource) throws -> T? { CoreStore.assert( self.isRunningInAllowedQueue(), @@ -69,9 +69,9 @@ public extension BaseDataTransaction { - parameter source: the object to import values from - throws: an `Error` thrown from any of the `ImportableObject` methods */ - public func importObject( + public func importObject( _ object: T, - source: T.ImportSource) throws where T: DynamicObject, T: ImportableObject { + source: T.ImportSource) throws { CoreStore.assert( self.isRunningInAllowedQueue(), @@ -97,9 +97,9 @@ public extension BaseDataTransaction { - throws: an `Error` thrown from any of the `ImportableObject` methods - returns: the array of created `ImportableObject` instances */ - public func importObjects( + public func importObjects( _ into: Into, - sourceArray: S) throws -> [T] where T: DynamicObject, T: ImportableObject, S.Iterator.Element == T.ImportSource { + sourceArray: S) throws -> [T] where S.Iterator.Element == T.ImportSource { CoreStore.assert( self.isRunningInAllowedQueue(), @@ -133,9 +133,9 @@ public extension BaseDataTransaction { - throws: an `Error` thrown from any of the `ImportableUniqueObject` methods - returns: the created/updated `ImportableUniqueObject` instance, or `nil` if the import was ignored */ - public func importUniqueObject( + public func importUniqueObject( _ into: Into, - source: T.ImportSource) throws -> T? where T: DynamicObject, T: ImportableUniqueObject { + source: T.ImportSource) throws -> T? { CoreStore.assert( self.isRunningInAllowedQueue(), @@ -185,10 +185,10 @@ public extension BaseDataTransaction { - throws: an `Error` thrown from any of the `ImportableUniqueObject` methods - returns: the array of created/updated `ImportableUniqueObject` instances */ - public func importUniqueObjects( + public func importUniqueObjects( _ into: Into, sourceArray: S, - 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 { + preProcess: @escaping (_ mapping: [T.UniqueIDType: T.ImportSource]) throws -> [T.UniqueIDType: T.ImportSource] = { $0 }) throws -> [T] where S.Iterator.Element == T.ImportSource { CoreStore.assert( self.isRunningInAllowedQueue(), diff --git a/Sources/Observing/ListMonitor.swift b/Sources/Observing/ListMonitor.swift index 4d5a53e..78cb88b 100644 --- a/Sources/Observing/ListMonitor.swift +++ b/Sources/Observing/ListMonitor.swift @@ -71,6 +71,11 @@ public final class ListMonitor: Hashable { // MARK: Public (Accessors) + /** + The type for the objects contained bye the `ListMonitor` + */ + public typealias ObjectType = T + /** Returns the object at the given index within the first section. This subscript indexer is typically used for `ListMonitor`s created with `monitorList(_:)`. diff --git a/Sources/Observing/ObjectMonitor.swift b/Sources/Observing/ObjectMonitor.swift index 8ab8047..51f6f87 100644 --- a/Sources/Observing/ObjectMonitor.swift +++ b/Sources/Observing/ObjectMonitor.swift @@ -42,6 +42,11 @@ import CoreData @available(OSX 10.12, *) public final class ObjectMonitor: Equatable { + /** + The type for the object contained by the `ObjectMonitor` + */ + public typealias ObjectType = EntityType + /** Returns the `NSManagedObject` instance being observed, or `nil` if the object was already deleted. */