<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppleArchive",
  "identifier" : "/documentation/AppleArchive/ArchiveStream/withStream(wrapping:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Apple Archive",
      "AppleArchive"
    ],
    "preciseIdentifier" : "s:12AppleArchive0B6StreamC04withC08wrapping_q_x_q_ACKXEtKRlzCAA0bC8ProtocolRzr0_lFZ"
  },
  "title" : "withStream(wrapping:_:)"
}
-->

# withStream(wrapping:_:)

Calls the given closure with an archive stream instance mapped to an object that conforms to the archive stream protocol.

```
static func withStream<C, E>(wrapping instance: C, _ body: (ArchiveStream) throws -> E) throws -> E where C : AnyObject, C : ArchiveStreamProtocol
```

## Parameters

`instance`

The object that the new archive stream wraps.

`body`

A closure with the archive stream passed as a parameter.

## Return Value

The result of the closure.

---

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)