---
title: "detectedValues(for:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nspasteboarditem/detectedvalues(for:)"
---

# detectedValues(for:)

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

## Declaration

```swift
func detectedValues(for keyPaths: Set<PartialKeyPath<NSPasteboardItem.DetectedValues>>) async throws -> NSPasteboardItem.DetectedValues
```

## Parameters

- `keyPaths`: The patterns to detect on the pasteboard.

## Return Value

Return Value An NSPasteboard.DetectedValues instance containing the values for the patterns detected on the pasteboard item.

## Discussion

Discussion For details about the types returned for each pattern, see NSPasteboard.DetectedValues. The following example shows how to use this method to find links in each item on the pasteboard: guard let pasteboardItems = NSPasteboard.general.pasteboardItems else { return } for (index, item) in pasteboardItems.enumerated() {     do {         let valueResults = try await item.detectedValues(for: [\.links])         let links = valueResults.links         guard !links.isEmpty else {             print ("Item \(index) - No links found in item.")             continue         }         for link in links {             print("Item \(index) - Link retrieved: \(link.url).")         }     } catch {         print("Item \(index) - Error: \(error).")     } } important: If the system finds a match when calling this method, the system informs the person using the app that the app is trying to read the contents of the pasteboard. If the person denies access to the pasteboard, the method throws an error.

## See Also

### Detecting patterns and metadata in pasteboard items

- [detectedPatterns(for:)](appkit/nspasteboarditem/detectedpatterns(for:).md)
- [NSPasteboardItem.DetectedValues](appkit/nspasteboarditem/detectedvalues.md)
- [detectedMetadata(for:)](appkit/nspasteboarditem/detectedmetadata(for:).md)
- [NSPasteboardItem.DetectedMetadata](appkit/nspasteboarditem/detectedmetadata.md)
