Contents

indexPathsToDeleteForSupplementaryView(ofKind:)

Returns the index paths for any supplementary views that the layout object wants to remove from the collection view.

Declaration

func indexPathsToDeleteForSupplementaryView(ofKind elementKind: NSCollectionView.SupplementaryElementKind) -> Set<IndexPath>

Parameters

  • elementKind:

    The type of the supplementary views to remove.

Return Value

The set of NSIndexPath objects representing the supplementary views to remove, or an empty array if you do not want to remove any supplementary views.

Discussion

When your app inserts or deletes items or sections in the collection view, the collection view calls this method for each of the registered supplementary view types. The default implementation returns an empty array, but you can override it and return index paths for each supplementary view you want to remove. For example, when a section is removed, you might want to remove the supplementary views associated with that section. In that case, you would add index paths to the array that contain the section numbers that were removed.

The index paths you return should always contain a valid section number, but the item number is optional. The item number is necessary only if you support multiple supplementary views of the same type in a single section. If you do, your layout object can use the item numbers internally to differentiate the supplementary views.

Subclasses are expected to override this method, as needed, and provide any appropriate index paths.

See Also

Responding to Collection View Updates