<!--
{
  "availability" : [
    "macOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Virtualization",
  "identifier" : "/documentation/Virtualization/VZDiskImageStorageDeviceAttachment/init(url:readOnly:)-9qeco",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Virtualization"
    ],
    "preciseIdentifier" : "c:objc(cs)VZDiskImageStorageDeviceAttachment(im)initWithURL:readOnly:error:"
  },
  "title" : "init(url:readOnly:)"
}
-->

# init(url:readOnly:)

Creates the attachment object from the specified disk image.

```
init(url: URL, readOnly: Bool) throws
```

## Parameters

`url`

A URL that points to a local disk image in RAW format.

`readOnly`

A Boolean that indicates whether to configure the disk image as read-only. Specify <doc://com.apple.documentation/documentation/Swift/true> to prevent the guest operating system from writing to the disk image, and <doc://com.apple.documentation/documentation/Swift/false> to allow writing.

## Return Value

In Swift the methods returns an attachment object; in Objective-C the methods returns an attachment object on success, or `nil` if an error occurred

## 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)