---
title: "MIDIDeviceDispose(_:)"
framework: coremidi
role: symbol
role_heading: Function
path: "coremidi/mididevicedispose(_:)"
---

# MIDIDeviceDispose(_:)

Disposes of a MIDI device.

## Declaration

```swift
func MIDIDeviceDispose(_ device: MIDIDeviceRef) -> OSStatus
```

## Parameters

- `device`: The device to dispose.

## Return Value

Return Value An OSStatus result code.

## Discussion

Discussion Drivers may call this function to dispose of device objects that they haven’t already added to the system using MIDISetupAddDevice(_:). To remove a device after adding it to the session, call MIDISetupRemoveDevice(_:). Nondrivers can’t call this function, and instead must call MIDISetupAddDevice(_:) and MIDISetupRemoveDevice(_:).

## See Also

### Managing Device Lifecyle

- [MIDIDeviceCreate(_:_:_:_:_:)](coremidi/mididevicecreate(_:_:_:_:_:).md)
- [MIDIDeviceRef](coremidi/midideviceref.md)
