mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-05-05 23:43:46 +02:00
Merge pull request #157 from ruslanskorb/fetched-objects-dynamicCast
Use `dynamicCast()` to cast `fetchedObjects` to `[T]?` without checking the type.
This commit is contained in:
@@ -202,7 +202,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.fetchedObjects as? [T]) ?? []
|
return self.fetchedResultsController.dynamicCast().fetchedObjects ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -371,7 +371,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.fetchedObjects as? [T] ?? []).index(of: object)
|
return (self.fetchedResultsController.dynamicCast().fetchedObjects ?? []).index(of: object)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user