KBAFetchedResultsObserver

@interface KBAFetchedResultsObserver<ResultType : id <NSFetchRequestResult>>
    : NSObject

KBAFetchedResultsObserver is an NSObject subclass that wraps an instance of NSFetchedResultsController and handles updating a view instance in response to its changes.

  • Set and get the delegate of the receiver.

    See

    KBAFetchedResultsObserverDelegate

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) id<KBAFetchedResultsObserverDelegate> delegate;
  • Set and get the predicate of the original fetch request that was passed in during initialization. Setting this to a new value will reload the fetched objects.

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) NSPredicate *predicate;
  • Set and get the table view instance the receiver should manage.

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) UITableView *tableView;
  • Set and get the collection view instance the receiver should manage.

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) UICollectionView *collectionView;
  • Get the fetched objects from the underlying fetched results controller.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSArray<ResultType> *fetchedObjects;
  • Get the fetched sections from the underlying fetched results controller.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSArray<id<NSFetchedResultsSectionInfo>> *fetchedSections;
  • Calls through to initWithFetchRequest:context:sectionNameKeyPath:cacheName:, passing nil for sectionNameKeyPath and cacheName.

    Declaration

    Objective-C

    - (nonnull instancetype)
        initWithFetchRequest:(nonnull NSFetchRequest<ResultType> *)fetchRequest
                     context:(nonnull NSManagedObjectContext *)context;
  • Creates and returns an initialized instance with the provided parameters.

    Declaration

    Objective-C

    - (nonnull instancetype)
        initWithFetchRequest:(nonnull NSFetchRequest<ResultType> *)fetchRequest
                     context:(nonnull NSManagedObjectContext *)context
          sectionNameKeyPath:(nullable NSString *)sectionNameKeyPath
                   cacheName:(nullable NSString *)cacheName;

    Parameters

    fetchRequest

    The fetch request to use when fetching objects from the context

    context

    The context from which to fetch objects

    sectionNameKeyPath

    The key path to use in order to group objects into sections

    cacheName

    The name to use when caching objects

    Return Value

    The initialized instance

  • Unavailable

    Undocumented

    Declaration

    Objective-C

    - (instancetype)init NS_UNAVAILABLE;
  • Unavailable

    Undocumented

    Declaration

    Objective-C

    + (instancetype)new NS_UNAVAILABLE;
  • Reload the fetched objects and any views being managed by the receiver.

    Declaration

    Objective-C

    - (void)reloadFetchedObjects;
  • Returns the fetched object at the provided indexPath.

    Declaration

    Objective-C

    - (nonnull ResultType)objectAtIndexPath:(nonnull NSIndexPath *)indexPath;

    Parameters

    indexPath

    The index path at which to fetch an object

    Return Value

    The fetched object

  • Returns the index path for the fetched object, or nil if no such index path exists.

    Declaration

    Objective-C

    - (nullable NSIndexPath *)indexPathForObject:(nonnull ResultType)object;

    Parameters

    object

    The fetched object

    Return Value

    The corresponding index path or nil