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

# withStream(wrapping:_:)

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

## Declaration

```swift
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

Return Value The result of the closure.

## See Also

### Using Custom Streams

- [customStream(instance:)](applearchive/archivestream/customstream(instance:).md)
