---
title: "withStream(wrapping:_:)"
framework: applearchive
role: symbol
role_heading: Type Method
path: "applearchive/archivebytestream/withstream(wrapping:_:)"
---

# withStream(wrapping:_:)

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

## Declaration

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

## Parameters

- `instance`: The object that the new archive stream wraps.
- `body`: A closure with the archive byte stream passed as a parameter.

## Return Value

Return Value The result of the closure.

## See Also

### Streaming with Custom Streams

- [customStream(instance:)](applearchive/archivebytestream/customstream(instance:).md)
- [sharedBufferPipe(capacity:)](applearchive/archivebytestream/sharedbufferpipe(capacity:).md)
