---
title: "detectPatterns(for:completionHandler:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uipasteboard/detectpatterns(for:completionhandler:)-5zlnd"
---

# detectPatterns(for:completionHandler:)

Determines whether the first pasteboard item matches the specified patterns, without notifying the user.

## Declaration

```swift
func detectPatterns(for patterns: Set<UIPasteboard.DetectionPattern>, completionHandler: @escaping (Result<Set<UIPasteboard.DetectionPattern>, any Error>) -> ())
```

## Parameters

- `patterns`: The patterns to detect on the pasteboard.
- `completionHandler`: A closure that the system invokes after detecting patterns on the pasteboard. The closure receives a Result instance that contains either a set with the patterns found on the pasteboard or an error if detection failed.

## 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

### Deprecated

- [isPersistent](uikit/uipasteboard/ispersistent.md)
- [setPersistent(_:)](uikit/uipasteboard/setpersistent(_:).md)
- [detectPatterns(for:inItemSet:completionHandler:)](uikit/uipasteboard/detectpatterns(for:initemset:completionhandler:)-29iwn.md)
- [detectValues(for:completionHandler:)](uikit/uipasteboard/detectvalues(for:completionhandler:)-9p2ff.md)
- [detectValues(for:inItemSet:completionHandler:)](uikit/uipasteboard/detectvalues(for:initemset:completionhandler:)-8y0iw.md)
