<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGEvent/init(withDataAllocator:data:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "c:@F@CGEventCreateFromData"
  },
  "title" : "init(withDataAllocator:data:)"
}
-->

# init(withDataAllocator:data:)

Returns a Quartz event created from a flattened data representation of the event.

```
init?(withDataAllocator allocator: CFAllocator?, data: CFData?)
```

## Parameters

`allocator`

The allocator to use to allocate memory for the event object. To use the current default allocator, pass `NULL` or `kCFAllocatorDefault`.

`data`

The flattened data representation of the event to reconstruct.

## Return Value

An event built from the flattened data representation, or `NULL` if the `eventData` parameter is invalid.

## Discussion

You can use this function to reconstruct a Quartz event received by network transport from another system.

---

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)