<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSImage/canInit(with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSImage(cm)canInitWithPasteboard:"
  },
  "title" : "canInit(with:)"
}
-->

# canInit(with:)

Tests whether the image can create an instance of itself using pasteboard data.

```
class func canInit(with pasteboard: NSPasteboard) -> Bool
```

## Parameters

`pasteboard`

The pasteboard containing the image data.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the receiver knows how to handle the data on the pasteboard; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

This method uses the `NSImageRep` class method [`imageUnfilteredPasteboardTypes()`](/documentation/AppKit/NSImageRep/imageUnfilteredPasteboardTypes()) to find a class that can handle the data in the specified pasteboard. If you create your own `NSImageRep` subclasses, override the [`imageUnfilteredPasteboardTypes()`](/documentation/AppKit/NSImageRep/imageUnfilteredPasteboardTypes()) method to notify `NSImage` of the pasteboard types your class supports.

## See Also

[`imagePasteboardTypes()`](/documentation/AppKit/NSImage/imagePasteboardTypes())

Returns an array of strings identifying the pasteboard types supported directly by the registered image representation objects.



---

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)