---
title: IOService
framework: driverkit
role: symbol
role_heading: Class
path: driverkit/ioservice
---

# IOService

The base class for managing the setup and registration of your driver.

## Declaration

```occ
class IOService;
```

## Mentioned in

Creating a Driver Using the DriverKit SDK

## Overview

Overview An IOService object is the base class the system uses to represent all devices and device-related interfaces. When the user plugs in a device, the system creates one or more service objects to manage interactions with that device. One service object represents the device itself, and additional service objects represent the interfaces or communication protocols that the device supports. For example, the driver for a USB camera that supports multiple video and audio protocols might define different service objects for each protocol. When the user plugs in a device, the system looks for the service objects that best match the device’s capabilities. Apple’s built-in driver families support most device types and a large array of standard interfaces. You provide custom service objects to support your device’s custom behaviors. In most cases, you subclass a child of IOService such as IOUSBHostInterface, instead of IOService itself. Use the methods of this class to do the following: Handle the initialization, setup, and teardown of your driver. View and manage the I/O Registry entry for the device or interface. Configure the dispatch queue on which to execute your code. Respond to power-level changes For additional information about how to implement services for a particular type of device, see the service subclasses in HIDDriverKit, USBDriverKit, NetworkingDriverKit, SerialDriverKit, and USBSerialDriverKit. Adding Member Variables to Your Custom Subclass Don’t declare custom member variables directly in your IOService subclass. Instead, DriverKit requires you to define all variables in a separate structure. During initialization, allocate a block of memory for that structure and assign that block to the system-provided ivars variable of your service class. The following code example shows you how to define the structure and allocate it in the init method of your service class. struct MyCustomKeyboardDriver_IVars {     OSArray *elements;          struct {         OSArray *elements;     } keyboard; };

bool MyCustomKeyboardDriver::init() {    if (!super::init()) {return false;}         // Allocate memory for the instance variables.    ivars = IONewZero(MyCustomKeyboardDriver_IVars, 1);    if (!ivars) {return false;}      exit:    return true; }

Deallocate any memory that you allocate for your custom variables in the free method of your class.

## Topics

### Running the Service

- [init](driverkit/ioservice/init.md)
- [Start](driverkit/ioservice/start.md)
- [Stop](driverkit/ioservice/stop.md)
- [free](driverkit/ioservice/free.md)

### Registering the Service with IOKit

- [RegisterService](driverkit/ioservice/registerservice.md)
- [SetName](driverkit/ioservice/setname.md)
- [GetRegistryEntryID](driverkit/ioservice/getregistryentryid.md)
- [IOServiceName](driverkit/ioservicename.md)

### Managing the Registry Properties

- [CopyProperties](driverkit/ioservice/copyproperties.md)
- [SetProperties](driverkit/ioservice/setproperties.md)
- [SearchProperty](driverkit/ioservice/searchproperty.md)
- [IOPropertyName](driverkit/iopropertyname.md)
- [IORegistryPlaneName](driverkit/ioregistryplanename.md)
- [Search Options](driverkit/3325572-search_options.md)

### Configuring Additional Dispatch Queues

- [SetDispatchQueue](driverkit/ioservice/setdispatchqueue.md)
- [CopyDispatchQueue](driverkit/ioservice/copydispatchqueue.md)

### Responding to Power-Level Changes

- [SetPowerState](driverkit/ioservice/setpowerstate.md)
- [ChangePowerState](driverkit/ioservice/changepowerstate.md)
- [Service Power Capabilities](driverkit/3325571-service_power_capabilities.md)

### Creating a New Service

- [NewUserClient](driverkit/ioservice/newuserclient.md)
- [Create](driverkit/ioservice/create.md)

### Instance Methods

- [AdjustBusy](driverkit/ioservice/adjustbusy.md)
- [ClientCrashed](driverkit/ioservice/clientcrashed.md)
- [ConfigureReport](driverkit/ioservice/configurereport.md)
- [CopyName](driverkit/ioservice/copyname.md)
- [CopyProviderProperties](driverkit/ioservice/copyproviderproperties.md)
- [CopySystemStateNotificationService](driverkit/ioservice/copysystemstatenotificationservice.md)
- [CoreAnalyticsSendEvent](driverkit/ioservice/coreanalyticssendevent.md)
- [CreateDefaultDispatchQueue](driverkit/ioservice/createdefaultdispatchqueue.md)
- [GetBusyState](driverkit/ioservice/getbusystate.md)
- [GetProvider](driverkit/ioservice/getprovider.md)
- [JoinPMTree](driverkit/ioservice/joinpmtree.md)
- [RemoveProperty](driverkit/ioservice/removeproperty.md)
- [RequireMaxBusStall](driverkit/ioservice/requiremaxbusstall.md)
- [SetLegend](driverkit/ioservice/setlegend.md)
- [SetPowerOverride](driverkit/ioservice/setpoweroverride.md)
- [StateNotificationItemCopy](driverkit/ioservice/statenotificationitemcopy.md)
- [StateNotificationItemCreate](driverkit/ioservice/statenotificationitemcreate.md)
- [StateNotificationItemSet](driverkit/ioservice/statenotificationitemset.md)
- [Stop_async](driverkit/ioservice/stop_async.md)
- [StringFromReturn](driverkit/ioservice/stringfromreturn.md)
- [Terminate](driverkit/ioservice/terminate.md)
- [UpdateReport](driverkit/ioservice/updatereport.md)
- [CallPlatformFunction](driverkit/ioservice/callplatformfunction.md)
- [CreatePMAssertion](driverkit/ioservice/createpmassertion.md)
- [ReleasePMAssertion](driverkit/ioservice/releasepmassertion.md)

### Type Methods

- [CreateKernelClassMatchingDictionary](driverkit/ioservice/createkernelclassmatchingdictionary-9b28.md)
- [CreateKernelClassMatchingDictionary](driverkit/ioservice/createkernelclassmatchingdictionary-3uqly.md)
- [CreateNameMatchingDictionary](driverkit/ioservice/createnamematchingdictionary-2nzta.md)
- [CreateNameMatchingDictionary](driverkit/ioservice/createnamematchingdictionary-206ej.md)
- [CreatePropertyMatchingDictionary](driverkit/ioservice/createpropertymatchingdictionary-4tuca.md)
- [CreatePropertyMatchingDictionary](driverkit/ioservice/createpropertymatchingdictionary-6o4ss.md)
- [CreateUserClassMatchingDictionary](driverkit/ioservice/createuserclassmatchingdictionary-4gpbj.md)
- [CreateUserClassMatchingDictionary](driverkit/ioservice/createuserclassmatchingdictionary-60ptx.md)

## Relationships

### Inherits From

- [OSObject](driverkit/osobject.md)

### Inherited By

- [IOUserClient](driverkit/iouserclient.md)
- [IOUserServer](driverkit/iouserserver.md)

## See Also

### Services

- [Creating a Driver Using the DriverKit SDK](driverkit/creating-a-driver-using-the-driverkit-sdk.md)
- [Debugging and testing system extensions](driverkit/debugging-and-testing-system-extensions.md)
