<!--
{
  "availability" : [
    "iOS: 14.0.0 - 15.0.0",
    "iPadOS: 14.0.0 - 15.0.0",
    "macCatalyst: -",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIPasteboard/detectPatterns(for:completionHandler:)-5zlnd",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "s:So12UIPasteboardC5UIKitE14detectPatterns3for17completionHandleryShySo0A16DetectionPatternaG_ys6ResultOyAIs5Error_pGctF"
  },
  "title" : "detectPatterns(for:completionHandler:)"
}
-->

# detectPatterns(for:completionHandler:)

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

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

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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)