---
title: Create
framework: kernel
role: symbol
role_heading: Type Method
path: kernel/osaction/3438206-create
---

# Create

Creates a new action object and configures it with your custom target object and callback method.

## Declaration

```occ
static kern_return_t Create(OSObject *target, uint64_t targetmsgid, uint64_t msgid, size_t referenceSize, OSAction **action);
```

## Parameters

- `target`: The object that contains the target method. The action object retains your target object.
- `targetmsgid`: The message ID for the custom method that you want the system to call. The doc://com.apple.driverkit/documentation/DriverKit/TYPE macro automatically generates a constant for this message ID that takes the form <Class>_<Method>_ID, where <Class> is the name of your class and <Method> is the name of your custom method.
- `msgid`: The message ID for the method the system expects to call. When using the doc://com.apple.driverkit/documentation/DriverKit/TYPE macro to declare conformance to DriverKit methods, specify the ID for the method you passed as a parameter to the doc://com.apple.driverkit/documentation/DriverKit/TYPE macro. For example, if you use the type macro to specify the doc://com.apple.usbdriverkit/documentation/USBDriverKit/IOUSBHostPipe/CompleteAsyncIO method of doc://com.apple.usbdriverkit/documentation/USBDriverKit/IOUSBHostPipe, specify IOUSBHostPipe_CompleteAsyncIO_ID.
- `referenceSize`: The additional number of bytes to allocate and store with your action object. Retrieve a pointer to this buffer later using the doc://com.apple.documentation/documentation/kernel/osaction/3438207-getreference method.
- `action`: A pointer to a variable for your action object. If this method creates the action object successfully, it returns that object in this parameter. It is a programmer error to specify NULL for this parameter.

## Return Value

Return Value kIOReturnSuccess on success, or another value if an error occurs. See Error Codes.

## Discussion

Discussion Use the custom constructor method generated by the TYPE macro, instead of this method. For more information on custom constructor methods for action objects, see TYPE.

## See Also

### Configuring the Action

- [free](kernel/osaction/3438209-free.md)
- [SetAbortedHandler](kernel/osaction/3438208-setabortedhandler.md)
