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

# userData

The data associated with a mouse-tracking event.

```
var userData: UnsafeMutableRawPointer? { get }
```

## Discussion

When you call [`addTrackingRect(_:owner:userData:assumeInside:)`](/documentation/AppKit/NSView/addTrackingRect(_:owner:userData:assumeInside:)) to set up a tracking rectangle, you can provide custom data to store in the event. AppKit makes that custom data available to you from this property.

This property is only valid when the event is of type [`NSMouseEntered`](/documentation/AppKit/NSMouseEntered) or [`NSMouseExited`](/documentation/AppKit/NSMouseExited). If you access this property for any other type of event, AppKit raises <doc://com.apple.documentation/documentation/Foundation/NSExceptionName/internalInconsistencyException>.

## See Also

[`enterExitEvent(with:location:modifierFlags:timestamp:windowNumber:context:eventNumber:trackingNumber:userData:)`](/documentation/AppKit/NSEvent/enterExitEvent(with:location:modifierFlags:timestamp:windowNumber:context:eventNumber:trackingNumber:userData:))

Creates and returns a new event object that describes a tracking-rectangle or cursor-update 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)