<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DiskImageKit",
  "identifier" : "/documentation/DiskImageKit/DiskImage/appending(_:)-4wifj",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "DiskImageKit"
    ],
    "preciseIdentifier" : "s:12DiskImageKit0aB0C9appendingyAA07StackedB0_pACnKF"
  },
  "title" : "appending(_:)"
}
-->

# appending(_:)

Appends a layer to this disk image, creating or extending a stack.

```
consuming func appending(_ layer: consuming DiskImage) throws -> any StackedImage
```

## Parameters

`layer`

An existing disk image to append as the new top layer.

## Return Value

A [`StackedImage`](/documentation/DiskImageKit/StackedImage) containing all layers.

## Discussion> Note: The framework allows only one cache layer per stacked disk image.

This method creates a stacked disk image by appending a layer to either a base image or an existing stacked image.
When the image is already a stacked image, the framework adds the new layer on top of the existing stack.

> Throws: ``doc://com.apple.diskimagekit/documentation/DiskImageKit/IncompatibleStackingError`` if the appended layer isn’t compatible with the stack.

---

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)