IGListAdapter

@interface IGListAdapter : NSObject

IGListAdapter objects provide an abstraction for feeds of objects in a UICollectionView by breaking each object into individual sections, called section controllers. These controllers (objects conforming to IGListSectionType) act as a data source and delegate for each section.

Feed implementations must act as the data source for an IGListAdapter in order to drive the objects and section controllers in a collection view.

  • The view controller that houses the adapter.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) UIViewController *viewController;
  • The collection view used with the adapter.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) IGListCollectionView *collectionView;
  • The object that acts as the data source for the list adapter.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<IGListAdapterDataSource>
        dataSource;

    Swift

    weak var dataSource: AnyObject? { get set }
  • The object that receives top-level events for section controllers.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<IGListAdapterDelegate> delegate;

    Swift

    weak var delegate: AnyObject? { get set }
  • The object that receives UICollectionViewDelegate events.

    @discussion This object /will not/ receive UIScrollViewDelegate events. Instead use scrollViewDelegate.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<UICollectionViewDelegate>
        collectionViewDelegate;

    Swift

    weak var collectionViewDelegate: AnyObject? { get set }
  • The object that receives UIScrollViewDelegate events.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<UIScrollViewDelegate>
        scrollViewDelegate;

    Swift

    weak var scrollViewDelegate: AnyObject? { get set }
  • A bitmask of experiments to conduct on the adapter.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) IGListExperiment experiments;

    Swift

    var experiments: Int32 { get set }
  • Initialize a new IGListAdapter object with a collection view, data source, and updating delegate.

    @discussion The working range is the number of objects beyond the visible objects (plus and minus) that should be notified when they are close to being visible. For instance, if you have 3 objects on screen and a working range of 2, the previous and succeeding 2 objects will be notified that they are within the working range. As you scroll the list the range is updated as objects enter and exit the working range.

    To opt out of using the working range, you can provide a value of 0.

    Declaration

    Objective-C

    - (nonnull instancetype)
     initWithUpdater:(nonnull id<IGListUpdatingDelegate>)updatingDelegate
      viewController:(nullable UIViewController *)viewController
    workingRangeSize:(NSUInteger)workingRangeSize;

    Parameters

    updatingDelegate

    An object that manages updates to the UICollectionView.

    viewController

    The view controller that will house the adapter.

    workingRangeSize

    The number of objects before and after the viewport to consider within the working range.

    Return Value

    A new IGListAdapter object.

  • Perform an update from the previous state of the data source. This is analagous to calling -[UICollectionView performBatchUpdates:completion:].

    Declaration

    Objective-C

    - (void)performUpdatesAnimated:(BOOL)animated
                        completion:(nullable IGListUpdaterCompletion)completion;

    Swift

    func performUpdatesAnimated(_ animated: Any!, completion: Any!)

    Parameters

    animated

    A flag indicating if the transition should be animated.

    completion

    A block executed when the update completes.

  • Perform an immediate reload of the data in the data source, discarding the old objectss.

    Declaration

    Objective-C

    - (void)reloadDataWithCompletion:(nullable IGListUpdaterCompletion)completion;

    Swift

    func reloadData(withCompletion completion: Any!)

    Parameters

    completion

    A block executed when the reload completes.

  • Reload the infra for specific objectss only.

    Declaration

    Objective-C

    - (void)reloadObjects:(nonnull NSArray *)objects;

    Swift

    func reloadObjects(_ objects: Any!)

    Parameters

    objects

    The objects to reload.

  • Query the section index of a list. Constant time lookup.

    Declaration

    Objective-C

    - (NSUInteger)sectionForSectionController:
        (nonnull IGListSectionController<IGListSectionType> *)sectionController;

    Swift

    func section(for sectionController: IGListSectionController!) -> Any!

    Parameters

    sectionController

    A list object.

    Return Value

    The section index of the list or NSNotFound.

  • Fetch an section controller for an object in the feed. Constant time lookup.

    See

    -[IGListAdapterDataSource listAdapter:sectionControllerForObject:]

    Declaration

    Objective-C

    - (__kindof IGListSectionController<IGListSectionType> *_Nullable)
    sectionControllerForObject:(nonnull id)object;

    Swift

    func sectionController(for object: Any!) -> IGListSectionController?

    Parameters

    object

    An object from the data source.

    Return Value

    An section controller or nil.

  • Fetch the object corresponding to a section in the feed. Constant time lookup.

    Declaration

    Objective-C

    - (nullable id)objectAtSection:(NSUInteger)section;

    Swift

    func object(atSection section: Any!) -> Any?

    Parameters

    section

    A section in the feed.

    Return Value

    An object or nil.

  • Fetch the section corresponding to an object in the feed. Constant time lookup.

    Declaration

    Objective-C

    - (NSUInteger)sectionForObject:(nonnull id)object;

    Swift

    func section(for object: Any!) -> Any!

    Parameters

    object

    An object in the feed

    Return Value

    A section index if found or NSNotFound.

  • A copy of all the objects currently powering the adapter.

    Declaration

    Objective-C

    - (nonnull NSArray *)objects;

    Swift

    func objects() -> Any!

    Return Value

    An array of objects.

  • An unordered array of the currently visible section controllers.

    Declaration

    Objective-C

    - (nonnull NSArray<IGListSectionController<IGListSectionType> *> *)
        visibleSectionControllers;

    Swift

    func visibleSectionControllers() -> Any!

    Return Value

    An array of section controllers.

  • Scroll to an object in the list adapter.

    Declaration

    Objective-C

    - (void)scrollToObject:(nonnull id)object
        supplementaryKinds:(nullable NSArray<NSString *> *)supplementaryKinds
           scrollDirection:(UICollectionViewScrollDirection)scrollDirection
                  animated:(BOOL)animated;

    Swift

    func scroll(to object: Any!, supplementaryKinds: Any!, scrollDirection: Any!, animated: Any!)

    Parameters

    object

    The object to scroll to.

    supplementaryKinds

    The types of supplementary views in the section.

    scrollDirection

    A flag indicating the direction to scroll.

    animated

    A flag indicating if the transition should be animated.

  • Query the size of a cell at the specified index path.

    Declaration

    Objective-C

    - (CGSize)sizeForItemAtIndexPath:(nonnull NSIndexPath *)indexPath;

    Swift

    func sizeForItem(atIndexPath indexPath: Any!) -> Any!

    Parameters

    indexPath

    The index path of the cell.

    Return Value

    The size of the cell.

  • Query the size of a supplementary view in the list at the specified index path.

    Declaration

    Objective-C

    - (CGSize)sizeForSupplementaryViewOfKind:(nonnull NSString *)elementKind
                                 atIndexPath:(nonnull NSIndexPath *)indexPath;

    Swift

    func sizeForSupplementaryView(ofKind elementKind: Any!, atIndexPath indexPath: Any!) -> Any!

    Parameters

    elementKind

    The kind of supplementary view.

    indexPath

    The index path of the supplementary view.

    Return Value

    The size of the supplementary view.

  • Undocumented

    Declaration

    Objective-C

    @interface IGListAdapter : NSObject
  • Undocumented

    Declaration

    Objective-C

    @interface IGListAdapter : NSObject