mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-15 21:53:39 +01:00
added utility for ListMonitor to return the index/indexPath of a specified object
This commit is contained in:
@@ -273,6 +273,28 @@ public final class ListMonitor<T: NSManagedObject> {
|
||||
return sections[section]
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the index of the `NSManagedObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
|
||||
|
||||
- parameter object: the `NSManagedObject` to search the index of
|
||||
- returns: the index of the `NSManagedObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
|
||||
*/
|
||||
public func indexOf(object: T) -> Int? {
|
||||
|
||||
return (self.fetchedResultsController.fetchedObjects as? [T] ?? []).indexOf(object)
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the `NSIndexPath` of the `NSManagedObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
|
||||
|
||||
- parameter object: the `NSManagedObject` to search the index of
|
||||
- returns: the `NSIndexPath` of the `NSManagedObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
|
||||
*/
|
||||
public func indexPathOf(object: T) -> NSIndexPath? {
|
||||
|
||||
return self.fetchedResultsController.indexPathForObject(object)
|
||||
}
|
||||
|
||||
/**
|
||||
Registers a `ListObserver` to be notified when changes to the receiver's list occur.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user