<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSEvent/init(eventRef:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSEvent(cm)eventWithEventRef:"
  },
  "title" : "init(eventRef:)"
}
-->

# init(eventRef:)

Creates and returns a new event object for a Carbon event.

```
init?(eventRef: UnsafeRawPointer)
```

## Parameters

`eventRef`

The `EventRef` opaque type to be associated with the created `NSEvent` object.

## Return Value

An autoreleased `NSEvent` object corresponding to `eventRef` or `nil` if `eventRef` cannot be converted into an equivalent `NSEvent` object.

## Discussion

This method is valid for all events. The created `NSEvent` object retains the `EventRef` object and is released when the `NSEvent` object is freed.

## See Also

[`eventRef`](/documentation/AppKit/NSEvent/eventRef)

An opaque Carbon type associated with this event.



---

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)