---
title: "collectionView(_:cancelPrefetchingForItemsAt:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uicollectionviewdatasourceprefetching/collectionview(_:cancelprefetchingforitemsat:)"
---

# collectionView(_:cancelPrefetchingForItemsAt:)

Cancels a previously triggered data prefetch request.

## Declaration

```swift
optional func collectionView(_ collectionView: UICollectionView, cancelPrefetchingForItemsAt indexPaths: [IndexPath])
```

## Parameters

- `collectionView`: The collection view issuing the cancellation of the prefetch request.
- `indexPaths`: The index paths that specify the locations of the items for which data is no longer required.

## Discussion

Discussion The collection view calls this method to cancel prefetch requests as cells scroll out of view. Your implementation of this method is responsible for canceling the operations initiated by a previous call to collectionView(_:prefetchItemsAt:). For further information about canceling an asynchronous data loading task, see Concurrency Programming Guide.

## See Also

### Managing data prefetching

- [Prefetching collection view data](uikit/prefetching-collection-view-data.md)
- [collectionView(_:prefetchItemsAt:)](uikit/uicollectionviewdatasourceprefetching/collectionview(_:prefetchitemsat:).md)
