---
title: "detectPatterns(for:inItemSet:completionHandler:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uipasteboard/detectpatterns(for:initemset:completionhandler:)-7ubl1"
---

# detectPatterns(for:inItemSet:completionHandler:)

Requests that the data detection system identify the patterns that you specify for the pasteboard items, and provide the patterns that it matches to your closure.

## Declaration

```swift
func detectPatterns(for keyPaths: Set<PartialKeyPath<UIPasteboard.DetectedValues>>, inItemSet itemSet: IndexSet?, completionHandler: @escaping (Result<[Set<PartialKeyPath<UIPasteboard.DetectedValues>>], any Error>) -> ())
```

## Parameters

- `keyPaths`: A set of key paths you use to indicate which types of patterns you want the data detection system to match.
- `itemSet`: A set of indexes you provide to indicate which pasteboard items the data detection system inspects to detect patterns.
- `completionHandler`: A closure you provide to process patterns the data detection system matches, or to handle errors.

## Discussion

Discussion Because this method only gives an indication of whether a pasteboard item matches a particular pattern and doesn’t allow the app to access the contents, the system doesn’t notify the user about reading the contents of the pasteboard.

## See Also

### Detecting patterns of content in pasteboard items

- [detectPatterns(for:completionHandler:)](uikit/uipasteboard/detectpatterns(for:completionhandler:)-23vwn.md)
- [detectedPatterns(for:)](uikit/uipasteboard/detectedpatterns(for:).md)
- [detectedPatterns(for:inItemSet:)](uikit/uipasteboard/detectedpatterns(for:initemset:).md)
- [detectValues(for:completionHandler:)](uikit/uipasteboard/detectvalues(for:completionhandler:)-6adre.md)
- [detectedValues(for:)](uikit/uipasteboard/detectedvalues(for:).md)
- [detectValues(for:inItemSet:completionHandler:)](uikit/uipasteboard/detectvalues(for:initemset:completionhandler:)-pm9l.md)
- [detectedValues(for:inItemSet:)](uikit/uipasteboard/detectedvalues(for:initemset:).md)
- [UIPasteboard.DetectedValues](uikit/uipasteboard/detectedvalues.md)
- [UIPasteboard.DetectionPattern](uikit/uipasteboard/detectionpattern.md)
