<!--
{
  "availability" : [
    "DriverKit: -",
    "iOS: -",
    "iPadOS: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "DriverKit",
  "identifier" : "/documentation/DriverKit/IOService",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "DriverKit"
    ],
    "preciseIdentifier" : "c:@S@IOService"
  },
  "title" : "IOService"
}
-->

# IOService

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

```
class IOService;
```

## Overview

An [`IOService`](/documentation/DriverKit/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`](/documentation/DriverKit/IOService) such as <doc://com.apple.documentation/documentation/USBDriverKit/IOUSBHostInterface>, instead of [`IOService`](/documentation/DriverKit/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 <doc://com.apple.documentation/documentation/HIDDriverKit>, <doc://com.apple.documentation/documentation/USBDriverKit>, <doc://com.apple.documentation/documentation/NetworkingDriverKit>, <doc://com.apple.documentation/documentation/SerialDriverKit>, and <doc://com.apple.documentation/documentation/USBSerialDriverKit>.

### Adding Member Variables to Your Custom Subclass

Don’t declare custom member variables directly in your [`IOService`](/documentation/DriverKit/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`](/documentation/DriverKit/IOService/init) method of your service class.

```objc
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`](/documentation/DriverKit/IOService/free) method of your class.

## Topics

### Running the Service

[`init`](/documentation/DriverKit/IOService/init)

Handles the basic initialization of the service.

[`Start`](/documentation/DriverKit/IOService/Start)

Starts the current service and associates it with the specified provider.

[`Stop`](/documentation/DriverKit/IOService/Stop)

Stops the service associated with the specified provider.

[`free`](/documentation/DriverKit/IOService/free)

Performs any final cleanup for the service.

### Registering the Service with IOKit

[`RegisterService`](/documentation/DriverKit/IOService/RegisterService)

Starts the registration process for the service and performs any additional matching.

[`SetName`](/documentation/DriverKit/IOService/SetName)

Sets the name of the service in the system’s registry.

[`GetRegistryEntryID`](/documentation/DriverKit/IOService/GetRegistryEntryID)

Returns the registry ID for the current service.

[`IOServiceName`](/documentation/DriverKit/IOServiceName)

A string type for setting the name of the service in the system’s registry.

### Managing the Registry Properties

[`CopyProperties`](/documentation/DriverKit/IOService/CopyProperties)

Returns the registry properties associated with the current service.

[`SetProperties`](/documentation/DriverKit/IOService/SetProperties)

Sends the dictionary of properties to the current service object.

[`SearchProperty`](/documentation/DriverKit/IOService/SearchProperty)

Searches for a property with the specified name in the current service or one of its parent services, and returns the corresponding value.

[`IOPropertyName`](/documentation/DriverKit/IOPropertyName)

A string type for specifying the name of a property in the system’s registry.

[`IORegistryPlaneName`](/documentation/DriverKit/IORegistryPlaneName)

A string type for specifying the name of a plane in the system’s registry.

[Search Options](/documentation/DriverKit/3325572-search_options)

Options to apply when searching for registry properties.

### Configuring Additional Dispatch Queues

[`SetDispatchQueue`](/documentation/DriverKit/IOService/SetDispatchQueue)

Associates a custom dispatch queue with the service and assigns the specified name to it.

[`CopyDispatchQueue`](/documentation/DriverKit/IOService/CopyDispatchQueue)

Gets the dispatch queue with the specified name from the current service.

### Responding to Power-Level Changes

[`SetPowerState`](/documentation/DriverKit/IOService/SetPowerState)

Updates the service in response to power-related changes for a provider.

[`ChangePowerState`](/documentation/DriverKit/IOService/ChangePowerState)

Changes the device’s power state to the specified level.

[Service Power Capabilities](/documentation/DriverKit/3325571-service_power_capabilities)

Constants that indicate the power state of a device.

### Creating a New Service

[`NewUserClient`](/documentation/DriverKit/IOService/NewUserClient)

Requests the creation of a new user client for the service.

[`Create`](/documentation/DriverKit/IOService/Create)

Requests the creation of a new service object.

### Instance Methods

[`AdjustBusy`](/documentation/DriverKit/IOService/AdjustBusy)

[`ClientCrashed`](/documentation/DriverKit/IOService/ClientCrashed)

[`ConfigureReport`](/documentation/DriverKit/IOService/ConfigureReport)

[`CopyName`](/documentation/DriverKit/IOService/CopyName)

[`CopyProviderProperties`](/documentation/DriverKit/IOService/CopyProviderProperties)

[`CopySystemStateNotificationService`](/documentation/DriverKit/IOService/CopySystemStateNotificationService)

[`CoreAnalyticsSendEvent`](/documentation/DriverKit/IOService/CoreAnalyticsSendEvent)

[`CreateDefaultDispatchQueue`](/documentation/DriverKit/IOService/CreateDefaultDispatchQueue)

[`GetBusyState`](/documentation/DriverKit/IOService/GetBusyState)

[`GetProvider`](/documentation/DriverKit/IOService/GetProvider)

[`JoinPMTree`](/documentation/DriverKit/IOService/JoinPMTree)

[`RemoveProperty`](/documentation/DriverKit/IOService/RemoveProperty)

[`RequireMaxBusStall`](/documentation/DriverKit/IOService/RequireMaxBusStall)

[`SetLegend`](/documentation/DriverKit/IOService/SetLegend)

[`SetPowerOverride`](/documentation/DriverKit/IOService/SetPowerOverride)

[`StateNotificationItemCopy`](/documentation/DriverKit/IOService/StateNotificationItemCopy)

[`StateNotificationItemCreate`](/documentation/DriverKit/IOService/StateNotificationItemCreate)

[`StateNotificationItemSet`](/documentation/DriverKit/IOService/StateNotificationItemSet)

[`Stop_async`](/documentation/DriverKit/IOService/Stop_async)

[`StringFromReturn`](/documentation/DriverKit/IOService/StringFromReturn)

[`Terminate`](/documentation/DriverKit/IOService/Terminate)

[`UpdateReport`](/documentation/DriverKit/IOService/UpdateReport)

### Type Methods

[`CreateKernelClassMatchingDictionary`](/documentation/DriverKit/IOService/CreateKernelClassMatchingDictionary-9b28)

[`CreateKernelClassMatchingDictionary`](/documentation/DriverKit/IOService/CreateKernelClassMatchingDictionary-3uqly)

[`CreateNameMatchingDictionary`](/documentation/DriverKit/IOService/CreateNameMatchingDictionary-2nzta)

[`CreateNameMatchingDictionary`](/documentation/DriverKit/IOService/CreateNameMatchingDictionary-206ej)

[`CreatePropertyMatchingDictionary`](/documentation/DriverKit/IOService/CreatePropertyMatchingDictionary-4tuca)

[`CreatePropertyMatchingDictionary`](/documentation/DriverKit/IOService/CreatePropertyMatchingDictionary-6o4ss)

[`CreateUserClassMatchingDictionary`](/documentation/DriverKit/IOService/CreateUserClassMatchingDictionary-4gpbj)

[`CreateUserClassMatchingDictionary`](/documentation/DriverKit/IOService/CreateUserClassMatchingDictionary-60ptx)



---

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)