<!--
{
  "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/detectValues(for:completionHandler:)-9p2ff",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "s:So12UIPasteboardC5UIKitE12detectValues3for17completionHandleryShySo0A16DetectionPatternaG_ys6ResultOySDyAHypGs5Error_pGctF"
  },
  "title" : "detectValues(for:completionHandler:)"
}
-->

# detectValues(for:completionHandler:)

Determines whether the first pasteboard item matches the specified patterns, reading the contents if it finds a match.

```
func detectValues(for patterns: Set<UIPasteboard.DetectionPattern>, completionHandler: @escaping (Result<[UIPasteboard.DetectionPattern : Any], 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 dictionary with the patterns found on the pasteboard or an error if detection failed. If the `Result` instance contains a dictionary, the keys specify the matched pattern, and the value specifies the content of the pasteboard.

## Discussion

> Important:
> Calling this method notifies the user that the app has read the contents of the pasteboard.

For details about the types returned for each pattern, see [`UIPasteboard.DetectionPattern`](/documentation/UIKit/UIPasteboard/DetectionPattern).

---

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)