<!--
{
  "availability" : [
    "DriverKit: -",
    "iOS: -",
    "iPadOS: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "DriverKit",
  "identifier" : "/documentation/DriverKit/IODataQueueDispatchSource/SetDataAvailableHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "DriverKit"
    ],
    "preciseIdentifier" : "c:@S@IODataQueueDispatchSource@F@SetDataAvailableHandler#*$@S@OSAction#"
  },
  "title" : "SetDataAvailableHandler"
}
-->

# SetDataAvailableHandler

Sets the handler block to run when another object adds data to the queue.

```
virtual kern_return_t SetDataAvailableHandler(OSAction *action);
```

## Parameters

`action`

The [`OSAction`](/documentation/DriverKit/OSAction) instance specifying the callback method. The data queue retains this object until you call this method again or call [`Cancel`](/documentation/DriverKit/IODataQueueDispatchSource/Cancel). This queue executes the action’s handler method on the action’s own dispatch queue.

## Return Value

[`kIOReturnSuccess`](/documentation/DriverKit/kIOReturnSuccess) on success, or another value if an error occurs. See [Error Codes](/documentation/DriverKit/error-codes).

---

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)