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

# canInit(with:)

Returns a Boolean value that indicates whether the receiver can initialize itself from the data on the specified pasteboard.

```
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 understands the format of the specified data and can use it to initialize itself; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

This method invokes the [`imageUnfilteredPasteboardTypes()`](/documentation/AppKit/NSImageRep/imageUnfilteredPasteboardTypes()) class method and checks the list of types returned by that method against the data types in `pasteboard`. If it finds a match, it returns <doc://com.apple.documentation/documentation/Swift/true>. When creating a subclass of `NSImageRep` that accepts image data from a non-default pasteboard type, override the [`imageUnfilteredPasteboardTypes()`](/documentation/AppKit/NSImageRep/imageUnfilteredPasteboardTypes()) method to assure this method returns the correct response.

---

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)