---
title: "encodeStream(writingTo:selectUsing:flags:threadCount:)"
framework: applearchive
role: symbol
role_heading: Type Method
path: "applearchive/archivestream/encodestream(writingto:selectusing:flags:threadcount:)"
---

# encodeStream(writingTo:selectUsing:flags:threadCount:)

Opens an encode output archive stream.

## Declaration

```swift
static func encodeStream(writingTo stream: ArchiveByteStream, selectUsing filter: ArchiveHeader.EntryFilter? = nil, flags: ArchiveFlags = [], threadCount: Int = 0) -> ArchiveStream?
```

## Parameters

- `stream`: The byte stream that recieves the encoded data.
- `filter`: A closure that’s called for each entry that’s received by the stream.
- `flags`: Flags that control the behavior of the operation.
- `threadCount`: The number of worker threads that the operation uses, set to 0 for default.

## Return Value

Return Value A new archive stream.

## See Also

### Encoding Data

- [withEncodeStream(writingTo:selectUsing:flags:threadCount:_:)](applearchive/archivestream/withencodestream(writingto:selectusing:flags:threadcount:_:).md)
