indexPath(forItemIdentifier:)
Returns an index path for the item with the specified identifier in the collection view.
Declaration
func indexPath(forItemIdentifier identifier: Any) -> IndexPath?Parameters
- identifier:
The identifier of the item in the collection view.
Return Value
The item’s index path, or nil if no item is found with the provided item identifier.
Discussion
This method is a constant time operation, O(1), which means you can look up an index path from its corresponding item identifier with no significant overhead.