---
title: "MIDIDestinationCreateWithProtocol(_:_:_:_:_:)"
framework: coremidi
role: symbol
role_heading: Function
path: "coremidi/mididestinationcreatewithprotocol(_:_:_:_:_:)"
---

# MIDIDestinationCreateWithProtocol(_:_:_:_:_:)

Creates a virtual destination in a client.

## Declaration

```swift
func MIDIDestinationCreateWithProtocol(_ client: MIDIClientRef, _ name: CFString, _ protocol: MIDIProtocolID, _ outDest: UnsafeMutablePointer<MIDIEndpointRef>, _ readBlock: @escaping MIDIReceiveBlock) -> OSStatus
```

## Parameters

- `client`: The client that owns the virtual destination.
- `name`: The name of the virtual destination.
- `protocol`: The MIDI protocol variant to deliver to the destination. The system automatically converts messages to this protocol as needed.
- `outDest`: On successful return, a pointer to the newly created destination.
- `readBlock`: A callback block the system invokes when a client sends MIDI data to the virtual destination.

## Return Value

Return Value An OSStatus result code.

## Discussion

Discussion Drivers don’t need to call this function. When they create devices and entities, the system automatically creates sources and destinations at that time. See kMIDIPropertyAdvanceScheduleTimeMuSec for information about the relationship between when a sender sends MIDI data to the destination and when it’s received. The system calls the read block on a separate high-priority thread owned by Core MIDI. tip: After creating a virtual source, assign it the same unique ID it had the last time your app created it. Doing so permits other clients to retain persistent references to your virtual source.

## See Also

### Endpoint management

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