# IGListSectionController Class Reference

# IGListSectionController

    @interface IGListSectionController : NSObject

The base class for section controllers used in a list. This class is intended to be subclassed.

- `-numberOfItems`

  Returns the number of items in the section.

  Note

  The count returned is used to drive the number of cells displayed for this section controller. The default implementation returns 1. Calling super is not required.

  #### Declaration

  Objective-C

      - (NSInteger)numberOfItems;

  Swift

      func numberOfItems() -> Int

  #### Return Value

  A count of items in the list.

- `-sizeForItemAtIndex:`

  The specific size for the item at the specified index.

  Note

  The returned size is not guaranteed to be used. The implementation may query sections for their layout information at will, or use its own layout metrics. For example, consider a dynamic-text sized list versus a fixed height-and-width grid. The former will ask each section for a size, and the latter will likely not. The default implementation returns size zero. Calling super is not required.

  #### Declaration

  Objective-C

      - (CGSize)sizeForItemAtIndex:(NSInteger)index;

  Swift

      func sizeForItem(at index: Int) -> CGSize

  #### Parameters

  `index` | The row index of the item.

  #### Return Value

  The size for the item at index.

- `-cellForItemAtIndex:`

  Return a dequeued cell for a given index.

  Note

  This is your opportunity to do any cell setup and configuration. The infrastructure requests a cell when it will be used on screen. You should never allocate new cells in this method, instead use the provided adapter to call one of the dequeue methods on the IGListCollectionContext. The default implementation will assert. You must override this method without calling super.

  Warning

  Don’t call this method to obtain a reference to currently dequeued cells: a new cell will be dequeued and returned, rather than the existing cell that you may have intended to retrieve. Instead, you can call `-cellForItemAtIndex:sectionController:` on `IGListCollectionContext` to obtain active cell references.

  #### Declaration

  Objective-C

      - (nonnull __kindof UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index;

  Swift

      func cellForItem(at index: Int) -> UICollectionViewCell

  #### Parameters

  `index` | The index of the requested row.

  #### Return Value

  A configured `UICollectionViewCell` subclass.

- `-didUpdateToObject:`

  Updates the section controller to a new object.

  Note

  When this method is called, all available contexts and configurations have been set for the section controller. This method will only be called when the object instance has changed, including from `nil` or a previous object. Calling super is not required.

  #### Declaration

  Objective-C

      - (void)didUpdateToObject:(nonnull id)object;

  Swift

      func didUpdate(to object: Any)

  #### Parameters

  `object` | The object mapped to this section controller.

- `-didSelectItemAtIndex:`

  Tells the section controller that the cell at the specified index path was selected.

  Note

  The default implementation does nothing. Calling super is not required.

  #### Declaration

  Objective-C

      - (void)didSelectItemAtIndex:(NSInteger)index;

  Swift

      func didSelectItem(at index: Int)

  #### Parameters

  `index` | The index of the selected cell.

- `-didDeselectItemAtIndex:`

  Tells the section controller that the cell at the specified index path was deselected.

  Note

  The default implementation does nothing. Calling super is not required.

  #### Declaration

  Objective-C

      - (void)didDeselectItemAtIndex:(NSInteger)index;

  Swift

      func didDeselectItem(at index: Int)

  #### Parameters

  `index` | The index of the deselected cell.

- `-didHighlightItemAtIndex:`

  Tells the section controller that the cell at the specified index path was highlighted.

  Note

  The default implementation does nothing. Calling super is not required.

  #### Declaration

  Objective-C

      - (void)didHighlightItemAtIndex:(NSInteger)index;

  Swift

      func didHighlightItem(at index: Int)

  #### Parameters

  `index` | The index of the highlighted cell.

- `-didUnhighlightItemAtIndex:`

  Tells the section controller that the cell at the specified index path was unhighlighted.

  Note

  The default implementation does nothing. Calling super is not required.

  #### Declaration

  Objective-C

      - (void)didUnhighlightItemAtIndex:(NSInteger)index;

  Swift

      func didUnhighlightItem(at index: Int)

  #### Parameters

  `index` | The index of the unhighlighted cell.

- `-canMoveItemAtIndex:`

  Identifies whether an object can be moved through interactive reordering.

  Note

  Interactive reordering is supported both for items within a single section, as well as for reordering sections themselves when sections contain only one item. The default implementation returns false.

  #### Declaration

  Objective-C

      - (BOOL)canMoveItemAtIndex:(NSInteger)index;

  Swift

      func canMoveItem(at index: Int) -> Bool

  #### Parameters

  `index` | The index of the object in the list.

  #### Return Value

  `YES` if the object is allowed to move, otherwise `NO`.

- `-moveObjectFromIndex:toIndex:`

  Notifies the section that a list object should move within a section as the result of interactive reordering.

  Note

  this method must be implemented if interactive reordering is enabled.

  #### Declaration

  Objective-C

      - (void)moveObjectFromIndex:(NSInteger)sourceIndex
                          toIndex:(NSInteger)destinationIndex;

  Swift

      func moveObject(from sourceIndex: Int, to destinationIndex: Int)

  #### Parameters

  `sourceIndex` | The starting index of the object.
  `destinationIndex` | The ending index of the object.

- `viewController`

  The view controller housing the adapter that created this section controller.

  Note

  Use this view controller to push, pop, present, or do other custom transitions.

  Warning

  It is considered very bad practice to cast this to a known view controller and call methods on it other than for navigations and transitions.

  #### Declaration

  Objective-C

      @property (readonly, nonatomic, nullable) UIViewController *viewController;

  Swift

      weak var viewController: UIViewController? { get }

- `collectionContext`

  A context object for interacting with the collection.

  Use this property for accessing the collection size, dequeuing cells, reloading, inserting, deleting, etc.

  #### Declaration

  Objective-C

      @property (readonly, nonatomic, nullable) id<IGListCollectionContext>
          collectionContext;

  Swift

      weak var collectionContext: ListCollectionContext? { get }

- `section`

  Returns the section within the list for this section controller.

  Note

  This value also relates to the section within a `UICollectionView` that this section controller’s cells belong. It also relates to the `-[NSIndexPath section]` value for individual cells within the collection view.

  #### Declaration

  Objective-C

      @property (readonly, assign, nonatomic) NSInteger section;

  Swift

      var section: Int { get }

- `isFirstSection`

  Returns `YES` if the section controller is the first section in the list, `NO` otherwise.

  #### Declaration

  Objective-C

      @property (readonly, assign, nonatomic) BOOL isFirstSection;

  Swift

      var isFirstSection: Bool { get }

- `isLastSection`

  Returns `YES` if the section controller is the last section in the list, `NO` otherwise.

  #### Declaration

  Objective-C

      @property (readonly, assign, nonatomic) BOOL isLastSection;

  Swift

      var isLastSection: Bool { get }

- `inset`

  The margins used to lay out content in the section controller.

  See

  `-[UICollectionViewFlowLayout sectionInset]`.

  #### Declaration

  Objective-C

      @property (assign, readwrite, nonatomic) UIEdgeInsets inset;

  Swift

      var inset: UIEdgeInsets { get set }

- `minimumLineSpacing`

  The minimum spacing to use between rows of items.

  See

  `-[UICollectionViewFlowLayout minimumLineSpacing]`.

  #### Declaration

  Objective-C

      @property (assign, readwrite, nonatomic) CGFloat minimumLineSpacing;

  Swift

      var minimumLineSpacing: CGFloat { get set }

- `minimumInteritemSpacing`

  The minimum spacing to use between items in the same row.

  See

  `-[UICollectionViewFlowLayout minimumInteritemSpacing]`.

  #### Declaration

  Objective-C

      @property (assign, readwrite, nonatomic) CGFloat minimumInteritemSpacing;

  Swift

      var minimumInteritemSpacing: CGFloat { get set }

- `supplementaryViewSource`

  The supplementary view source for the section controller. Can be `nil`.

  Note

  You may wish to return `self` if your section controller implements this protocol.

  #### Declaration

  Objective-C

      @property (readwrite, nonatomic, nullable) id<IGListSupplementaryViewSource>
          supplementaryViewSource;

  Swift

      weak var supplementaryViewSource: ListSupplementaryViewSource? { get set }

  #### Return Value

  An object that conforms to `IGListSupplementaryViewSource` or `nil`.

- `displayDelegate`

  An object that handles display events for the section controller. Can be `nil`.

  Note

  You may wish to return `self` if your section controller implements this protocol.

  #### Declaration

  Objective-C

      @property (readwrite, nonatomic, nullable) id<IGListDisplayDelegate>
          displayDelegate;

  Swift

      weak var displayDelegate: ListDisplayDelegate? { get set }

  #### Return Value

  An object that conforms to `IGListDisplayDelegate` or `nil`.

- `workingRangeDelegate`

  An object that handles working range events for the section controller. Can be `nil`.

  Note

  You may wish to return `self` if your section controller implements this protocol.

  #### Declaration

  Objective-C

      @property (readwrite, nonatomic, nullable) id<IGListWorkingRangeDelegate>
          workingRangeDelegate;

  Swift

      weak var workingRangeDelegate: ListWorkingRangeDelegate? { get set }

  #### Return Value

  An object that conforms to `IGListWorkingRangeDelegate` or `nil`.

- `scrollDelegate`

  An object that handles scroll events for the section controller. Can be `nil`.

  Note

  You may wish to return `self` if your section controller implements this protocol.

  #### Declaration

  Objective-C

      @property (readwrite, nonatomic, nullable) id<IGListScrollDelegate>
          scrollDelegate;

  Swift

      weak var scrollDelegate: ListScrollDelegate? { get set }

  #### Return Value

  An object that conforms to `IGListScrollDelegate` or `nil`.

- `transitionDelegate`

  An object that handles transition events for the section controller. Can be `nil`.

  Note

  You may wish to return `self` if your section controller implements this protocol.

  #### Declaration

  Objective-C

      @property (readwrite, nonatomic, nullable) id<IGListTransitionDelegate>
          transitionDelegate;

  Swift

      weak var transitionDelegate: IGListTransitionDelegate? { get set }

  #### Return Value

  An object that conforms to `IGListTransitionDelegat` or `nil`.

© 2019 Instagram. All rights reserved. (Last updated: 2019-11-20)

Generated by jazzy ♪♫ v0.12.0, a Realm project.