<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Dispatch",
  "identifier" : "/documentation/Dispatch/DispatchIO/init(type:io:queue:cleanupHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Dispatch"
    ],
    "preciseIdentifier" : "s:So14OS_dispatch_ioC8DispatchE4type0C05queue14cleanupHandlerA2bCE10StreamTypeO_ABSo0a1_b1_F0Cys5Int32Vctcfc"
  },
  "title" : "init(type:io:queue:cleanupHandler:)"
}
-->

# init(type:io:queue:cleanupHandler:)

Creates a new I/O channel from an existing I/O channel.

```
convenience init(type: DispatchIO.StreamType, io: DispatchIO, queue: DispatchQueue, cleanupHandler: @escaping (Int32) -> Void)
```

## Parameters

`type`

The access semantics for the channel. For a list of possible values, see [`DispatchIO.StreamType`](/documentation/Dispatch/DispatchIO/StreamType).

`io`

An existing channel.

`queue`

The dispatch queue on which to perform work.

`cleanupHandler`

The handler to execute once the channel is closed. This block has no return value and takes the following parameter:

- error: An `errno` condition if creating or opening the channel failed; otherwise, the value is `0`.

## Discussion

---

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)