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

# eventRef

An opaque Carbon type associated with this event.

```
var eventRef: UnsafeRawPointer? { get }
```

## Discussion

This method is valid for all types of events. The `EventRef` object is retained by the receiver, so it is valid as long as the `NSEvent` object is valid, and is released when the `NSEvent` object is freed. You can use `RetainEvent(_:)` to extend the lifetime of the `EventRef` object, with a corresponding `ReleaseEvent(_:)` when you are done with it.

The system typically creates user-input events with an associated `EventRef`. Other `NSEvent` objects create an `EventRef` when this property is first accessed, if possible. If there is no equivalent `NSEvent` for this event, the property is set to `NULL`.

## See Also

[`+  eventWithEventRef:`](/documentation/AppKit/NSEvent/init(eventRef:))

Creates and returns a new event object for a Carbon 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)