---
title: "randomAccessDecompressionStream(readingFrom:allocationLimit:flags:threadCount:)"
framework: applearchive
role: symbol
role_heading: Type Method
path: "applearchive/archivebytestream/randomaccessdecompressionstream(readingfrom:allocationlimit:flags:threadcount:)"
---

# randomAccessDecompressionStream(readingFrom:allocationLimit:flags:threadCount:)

Creates a decompression random-access input stream.

## Declaration

```swift
static func randomAccessDecompressionStream(readingFrom compressedStream: ArchiveByteStream, allocationLimit: Int = Int.max, flags: ArchiveFlags = [], threadCount: Int = 0) -> ArchiveByteStream?
```

## Parameters

- `compressedStream`: An input stream that provides compressed data.
- `allocationLimit`: The requested memory allocation size, in bytes. Set to 0 for lowest memory footprint or doc://com.apple.documentation/documentation/Swift/Int/max for best performance.
- `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 byte stream.

## Discussion

Discussion The operation reads compressed data from the suppled archive byte stream, compressedStream. The stream that the function returns implements read and seek methods. Pass allocationLimit as a hint to control the stream’s memory allocation for in-out buffers for each thread and cache for uncompressed data. The stream creation adjusts both the actual number of decompression threads and the cache size to attempt to satisfy the allocation request.

## See Also

### Decompressing Data

- [decompressionStream(readingFrom:flags:threadCount:)](applearchive/archivebytestream/decompressionstream(readingfrom:flags:threadcount:).md)
- [withDecompressionStream(readingFrom:flags:threadCount:_:)](applearchive/archivebytestream/withdecompressionstream(readingfrom:flags:threadcount:_:).md)
- [withRandomAccessDecompressionStream(readingFrom:allocationLimit:flags:threadCount:_:)](applearchive/archivebytestream/withrandomaccessdecompressionstream(readingfrom:allocationlimit:flags:threadcount:_:).md)
