---
title: "initWithIOService:queue:error:interestHandler:"
framework: iousbhost
role: symbol
role_heading: Instance Method
path: "iousbhost/iousbhostobject/initwithioservice:queue:error:interesthandler:"
---

# initWithIOService:queue:error:interestHandler:

Creates a USB host object and sets up a default communication channel to the kernel.

## Declaration

```occ
- (instancetype) initWithIOService:(io_service_t) ioService queue:(dispatch_queue_t) queue error:(NSError **) error interestHandler:(IOUSBHostInterestHandler) interestHandler;
```

## Parameters

- `ioService`: The service type of the doc://com.apple.documentation/documentation/kernel/iousbhostdevice or doc://com.apple.documentation/documentation/kernel/iousbhostinterface. The doc://com.apple.iousbhost/documentation/IOUSBHost/IOUSBHostObject keeps a reference to the service type and releases it during doc://com.apple.iousbhost/documentation/IOUSBHost/IOUSBHostObject/destroy().
- `queue`: A serial dispatch queue for servicable asynchronous input/output requests. By default, this method creates a serial queue on behalf of the client.
- `error`: An doc://com.apple.documentation/documentation/Foundation/NSError that contains an doc://com.apple.documentation/documentation/kernel/ioreturn value on failure.
- `interestHandler`: A callback for managing internal device state changes, such as termination.

## Return Value

Return Value An IOUSBHostObject instance, or nil on failure.

## Discussion

Discussion If the kernel IOUSBHostDevice or IOUSBHostInterface is already open for exclusive access, the method returns nil. The method establishes exclusive ownership of the io_service_t. important: When done with the object, call destroy().

## Topics

### Interest Handler

- [IOUSBHostInterestHandler](iousbhost/iousbhostinteresthandler.md)

## See Also

### Managing the Object Life Cycle

- [IOUSBHostObjectInitOptions](iousbhost/iousbhostobjectinitoptions.md)
- [initWithIOService:options:queue:error:interestHandler:](iousbhost/iousbhostobject/initwithioservice:options:queue:error:interesthandler:.md)
- [IOUSBHostInterestHandler](iousbhost/iousbhostinteresthandler.md)
- [ioService](iousbhost/iousbhostobject/ioservice.md)
- [queue](iousbhost/iousbhostobject/queue.md)
- [destroy()](iousbhost/iousbhostobject/destroy().md)
