---
title: "init(type:io:queue:cleanupHandler:)"
framework: dispatch
role: symbol
role_heading: Initializer
path: "dispatch/dispatchio/init(type:io:queue:cleanuphandler:)"
---

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

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

## Declaration

```swift
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 doc://com.apple.dispatch/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:

## See Also

### Creating a Dispatch I/O Object

- [init(type:fileDescriptor:queue:cleanupHandler:)](dispatch/dispatchio/init(type:filedescriptor:queue:cleanuphandler:).md)
- [init(type:path:oflag:mode:queue:cleanupHandler:)](dispatch/dispatchio/init(type:path:oflag:mode:queue:cleanuphandler:)-50rb0.md)
- [DispatchIO.StreamType](dispatch/dispatchio/streamtype.md)
