Classes

The following classes are available globally.

  • 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 subclassing to IGListSectionController) 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.

    See more

    Declaration

    Objective-C

    
    @interface IGListAdapter : NSObject

    Swift

    class ListAdapter : NSObject
  • An IGListAdapterUpdater is a concrete type that conforms to IGListUpdatingDelegate. It is an out-of-box updater for IGListAdapter objects to use.

    Note

    This updater performs re-entrant, coalesced updating for a list. It also uses a least-minimal diff for calculating UI updates when IGListAdapter calls -performUpdateWithCollectionView:fromObjects:toObjects:completion:.
    See more

    Declaration

    Objective-C

    
    @interface IGListAdapterUpdater : NSObject <IGListUpdatingDelegate>

    Swift

    class ListAdapterUpdater : NSObject, ListUpdatingDelegate
  • An instance of IGListBatchUpdateData takes section indexes and item index paths and performs cleanup on init in order to perform a crash-free update via -[UICollectionView performBatchUpdates:completion:].

    See more

    Declaration

    Objective-C

    
    @interface IGListBatchUpdateData : NSObject

    Swift

    class ListBatchUpdateData : NSObject
  • This section controller uses a data source to transform its top level object into an array of diffable view models. It then automatically binds each view model to cells via the IGListBindable protocol.

    Models used with IGListBindingSectionController should take special care to always return YES for identical objects. That is, any objects with matching -diffIdentifiers should always be equal, that way the section controller can create new view models via the data source, create a diff, and update the specific cells that have changed.

    In Objective-C, your -isEqualToDiffableObject: can simply be:

    - (BOOL)isEqualToDiffableObject:(id)object {
      return YES;
    }
    

    In Swift:

    func isEqual(toDiffableObject object: IGListDiffable?) -> Bool {
      return true
    }
    

    Only when -diffIdentifiers match is object equality compared, so you can assume the class is the same, and the instance has already been checked.

    See more

    Declaration

    Objective-C

    
    @interface IGListBindingSectionController < __covariant ObjectType
        : id <IGListDiffable>
    > : IGListSectionController @end
  • This UICollectionViewLayout subclass is for vertically or horizontally scrolling lists of data with variable widths and heights. It supports an infinite number of sections and items. All work is done on the main thread, and while extremely efficient, care must be taken not to stall the main thread in sizing delegate methods.

    This layout piggybacks on the mechanics of UICollectionViewFlowLayout in that:

    • Your UICollectionView data source must also conform to UICollectionViewDelegateFlowLayout
    • Header support given via UICollectionElementKindSectionHeader

    All UICollectionViewDelegateFlowLayout methods are required and used by this layout:

    - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
    - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section;
    - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section;
    - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section;
    - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section;
    

    In a vertically scrolling layout, sections and items are put into the same horizontal row until the max-x position of an item extends beyond the width of the collection view. When that happens, the item is newlined to the next row. The y position of that row is determined by the maximum height (including section insets) of the section/item of the previous row.

    Ex. of a section (2,0) with a large width causing a newline.

    |[ 0,0 ][ 1,0 ]         |
    |[         2,0         ]|
    

    A section with a non-zero height header will always cause that section to newline. Headers are always stretched to the width of the collection view, pinched with the section insets.

    Ex. of a section (2,0) with a header inset on the left/right.

    |[ 0,0 ][ 1,0 ]         |
    | >======header=======< |
    | [ 2,0 ]               |
    

    Section insets apply to items in the section no matter if they begin on a new row or are on the same row as a previous section.

    Ex. of a section (2) with multiple items and a left inset.

    |[ 0,0 ][ 1,0 ] >[ 2,0 ]|
    | >[ 2,1 ][ 2,2 ][ 2,3 ]|
    

    Interitem spacing applies to items and sections within the same row. Line spacing only applies to items within the same section.

    In a horizontally scrolling layout, sections and items are flowed vertically until they need to be newlined to the next column. Headers, if used, are stretched to the height of the collection view, minus the section insets.

    Please see the unit tests for more configuration examples and expected output.

    See more

    Declaration

    Objective-C

    
    @interface IGListCollectionViewLayout : UICollectionViewLayout

    Swift

    class ListCollectionViewLayout : UICollectionViewLayout
  • This class adds a helper layer to IGListSectionController to automatically store a generic object in didUpdateToObject:.

    See more

    Declaration

    Objective-C

    
    @interface IGListGenericSectionController <__covariant ObjectType> : IGListSectionController

    Swift

    class ListGenericSectionController
  • A result object returned when diffing with sections.

    See more

    Declaration

    Objective-C

    
    @interface IGListIndexPathResult : NSObject

    Swift

    class ListIndexPathResult : NSObject
  • A result object returned when diffing with indexes.

    See more

    Declaration

    Objective-C

    
    @interface IGListIndexSetResult : NSObject

    Swift

    class ListIndexSetResult : NSObject
  • An object representing a move between indexes.

    See more

    Declaration

    Objective-C

    
    @interface IGListMoveIndex : NSObject

    Swift

    class ListMoveIndex : NSObject
  • An object representing a move between indexes.

    See more

    Declaration

    Objective-C

    
    @interface IGListMoveIndexPath : NSObject

    Swift

    class ListMoveIndexPath : NSObject
  • An IGListReloadDataUpdater is a concrete type that conforms to IGListUpdatingDelegate. It is an out-of-box updater for IGListAdapter objects to use.

    Note

    This updater performs simple, synchronous updates using -[UICollectionView reloadData].

    Declaration

    Objective-C

    
    @interface IGListReloadDataUpdater : NSObject <IGListUpdatingDelegate>

    Swift

    class ListReloadDataUpdater : NSObject, ListUpdatingDelegate
  • The base class for section controllers used in a list. This class is intended to be subclassed.

    See more

    Declaration

    Objective-C

    
    @interface IGListSectionController : NSObject

    Swift

    class ListSectionController : NSObject
  • This section controller is meant to make building simple, single-cell lists easier. By providing the type of cell, a block to configure the cell, and a block to return the size of a cell, you can use an IGListAdapter-powered list with a simpler architecture.

    See more

    Declaration

    Objective-C

    
    @interface IGListSingleSectionController : IGListSectionController

    Swift

    class ListSingleSectionController : ListSectionController
  • An instance of IGListStackedSectionController is a clustered section controller, composed of many child section controllers. It constructs and routes item-level indexes to the appropriate child section controller with a local index. This lets you build section controllers made up of individual units that can be shared and reused with other section controllers.

    For example, you can create a Comments section controller that displays lists of text that is used alongside photo, video, or slideshow section controllers. You then have four small and manageable section controllers instead of one huge class.

    See more

    Declaration

    Objective-C

    
    @interface IGListStackedSectionController : IGListSectionController

    Swift

    class ListStackedSectionController : ListSectionController