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

# canInit(with:)

Returns a Boolean value that indicates whether the image representation can initialize itself from the specified data.

```
class func canInit(with data: Data) -> Bool
```

## Parameters

`data`

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 should be overridden by subclasses. Note that this method does not need to do a comprehensive check of the image data; it should return <doc://com.apple.documentation/documentation/Swift/false> only if it knows it cannot initialize itself from the data.

---

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)