<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSImage/init(contentsOf:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSImage(im)initWithContentsOfURL:"
  },
  "title" : "init(contentsOf:)"
}
-->

# init(contentsOf:)

Initializes and returns an image object with the contents of the specified URL.

```
convenience init?(contentsOf url: URL)
```

## Parameters

`url`

The URL identifying the image.

## Return Value

An initialized `NSImage` object or `nil` if the method cannot create an image representation from the contents of the specified URL.

## Discussion

---

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)