<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DiskImageKit",
  "identifier" : "/documentation/DiskImageKit/StackedImage",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "DiskImageKit"
    ],
    "preciseIdentifier" : "s:12DiskImageKit07StackedB0P"
  },
  "title" : "StackedImage"
}
-->

# StackedImage

The protocol for stacked disk images that contain multiple layers.

```
protocol StackedImage : DiskImage
```

## Overview

A stacked disk image combines multiple layers into a single logical disk image.
The first layer (the bottom of the stack) is the base layer, and subsequent layers
are either cache or overlay layers that modify or cache the layers beneath.

The following example demonstrates how to create a stacked image.

```
let baseImage = try DiskImage(opening: .open(url: baseImageURL))
var stackedImage = try baseImage.appending(.asifLayer(url: cacheURL, type: .cache))
stackedImage = try stackedImage.appending(.asifLayer(url: shadowURL, type: .overlay))
```

## Topics

### Instance Properties

[`var layers: [DiskImage]`](/documentation/DiskImageKit/StackedImage/layers)

An array of all layers in the stack, from base (index 0) to top.

## Relationships

### Inherits From

[`DiskImage`](/documentation/DiskImageKit/DiskImage)

---

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)