---
title: "MIDIEndpointSetRefCons(_:_:_:)"
framework: coremidi
role: symbol
role_heading: Function
path: "coremidi/midiendpointsetrefcons(_:_:_:)"
---

# MIDIEndpointSetRefCons(_:_:_:)

Sets contextual data on an endpoint.

## Declaration

```swift
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

Return Value An OSStatus result code.

## Discussion

Discussion Drivers need an efficient way to translate from a 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. A typical use is for one refCon to refer to a device, and a second to refer to a port on the device.

## See Also

### Endpoint management

- [MIDIEndpointDispose(_:)](coremidi/midiendpointdispose(_:).md)
- [MIDIEndpointGetEntity(_:_:)](coremidi/midiendpointgetentity(_:_:).md)
- [MIDIEndpointGetRefCons(_:_:_:)](coremidi/midiendpointgetrefcons(_:_:_:).md)
- [MIDISourceCreateWithProtocol(_:_:_:_:)](coremidi/midisourcecreatewithprotocol(_:_:_:_:).md)
- [MIDIGetSource(_:)](coremidi/midigetsource(_:).md)
- [MIDIGetNumberOfSources()](coremidi/midigetnumberofsources().md)
- [MIDIDestinationCreateWithProtocol(_:_:_:_:_:)](coremidi/mididestinationcreatewithprotocol(_:_:_:_:_:).md)
- [MIDIGetDestination(_:)](coremidi/midigetdestination(_:).md)
- [MIDIGetNumberOfDestinations()](coremidi/midigetnumberofdestinations().md)
- [MIDIEndpointRef](coremidi/midiendpointref.md)
