<!--
{
  "availability" : [
    "macOS: 10.15.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSColorSampler/show(selectionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSColorSampler(im)showSamplerWithSelectionHandler:"
  },
  "title" : "show(selectionHandler:)"
}
-->

# show(selectionHandler:)

Displays the system color-sampling interface asynchronously and reports the selected color back to your app.

```
func show(selectionHandler: @escaping @Sendable (NSColor?) -> Void)
```

```
func sample() async -> NSColor?
```

## Parameters

`selectionHandler`

The handler block for processing the user-selected color. AppKit calls this block on your app’s main thread. This block has no return value and takes the following parameter:

- selectedColor: The selected color.

## Discussion

This method displays the color-sampling interface and returns immediately. The color-sampling interface magnifies the onscreen pixels and makes it easier for the user to select a single pixel. When the user clicks any mouse button, AppKit dismisses the interface and calls `selectionHandler` with the results.

---

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)