FetchedResultsDataProvider
public final class FetchedResultsDataProvider<Object> : NSObject, NSFetchedResultsControllerDelegate, DataProvider where Object : NSFetchRequestResult
FetchedResultsDataProvider
uses a NSFetchedResultsController
as a backing store to transform it into a data provider.
-
The fetched results controller which backs the data provider.
Declaration
Swift
public let fetchedResultsController: NSFetchedResultsController<Object>
-
An observable where one can subscribe to changes of data provider.
Declaration
Swift
public var observable: DataProviderObservable { get }
-
Creates an instance of
FetchedResultsDataProvider
backed by aNSFetchedResultsController
. Performs a fetch to populate the data.Throws
if fetching fails.Declaration
Swift
public init(fetchedResultsController: NSFetchedResultsController<Object>) throws
Parameters
fetchedResultsController
the fetched results controller backing the data provider.
-
Reconfigure the
NSFetchedResultsController
with a new fetch request. This will refetch all objects.Throws
if fetching failsDeclaration
Swift
public func reconfigure(with configure: (NSFetchedResultsController<Object>) -> Void) throws
Parameters
configure
a block to perform the reconfiguration.
-
Perform changes to your model object, which won`t result in an updated view. This can be helpful when performing a move operation amnd if the view is already in the correct state.
Declaration
Swift
public func performNonUIRelevantChanges(_ execute: () -> Void)
Parameters
execute
block to perform the changes in.
-
Returns an object for a given index path.
Declaration
Swift
public func object(at indexPath: IndexPath) -> Object
Parameters
indexPath
the index path to get the object for.
Return Value
the object at the given index path.
-
Returns the number of items in a given section.
Declaration
Swift
public func numberOfItems(inSection section: Int) -> Int
Parameters
section
the section.
Return Value
number of items in the given section.
-
Return the number of sections.
Declaration
Swift
public func numberOfSections() -> Int
Return Value
the number of sections.
-
Returns the index path of an object if it is contains in the data provider.
Declaration
Swift
public func indexPath(for object: Object) -> IndexPath?
Parameters
object
the object to get the index path for.
Return Value
the index path for the given object.
-
Undocumented
Declaration
Swift
public func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)
-
Undocumented
Declaration
Swift
public func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?)
-
Undocumented
Declaration
Swift
public func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange sectionInfo: NSFetchedResultsSectionInfo, atSectionIndex sectionIndex: Int, for type: NSFetchedResultsChangeType)
-
Undocumented
Declaration
Swift
public func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)