<!--
{
  "availability" : [
    "iOS: 4.2.0 -",
    "iPadOS: 4.2.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMIDI",
  "identifier" : "/documentation/CoreMIDI/MIDIEndpointSetRefCons(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core MIDI"
    ],
    "preciseIdentifier" : "c:@F@MIDIEndpointSetRefCons"
  },
  "title" : "MIDIEndpointSetRefCons(_:_:_:)"
}
-->

# MIDIEndpointSetRefCons(_:_:_:)

Sets contextual data on an endpoint.

```
func MIDIEndpointSetRefCons(_ endpt: MIDIEndpointRef, _ ref1: UnsafeMutableRawPointer?, _ ref2: UnsafeMutableRawPointer?) -> OSStatus
```

## Parameters

`endpt`

The endpoint to set the data on.

`ref1`

The first `refCon`.

`ref2`

The second `refCon`.

## Return Value

An OSStatus result code.

## Discussion

Drivers need an efficient way to translate from a [`MIDIEndpointRef`](/documentation/CoreMIDI/MIDIEndpointRef) (source or destination) to their own internal data structures corresponding to that endpoint. This function provides a way for the driver to assign its own data to endpoints.

The data you set isn’t persistent and needs to be reintialized in each call to [`Start`](/documentation/CoreMIDI/MIDIDriverInterface/Start).

A typical use is for one `refCon` to refer to a device, and a second to refer to a port on the device.

---

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)