Contents

detach(device:completionHandler:)

Detaches a USB device from the controller.

Declaration

func detach(device: any VZUSBDevice, completionHandler: @escaping ((any Error)?) -> Void)
func detach(device: any VZUSBDevice) async throws

Parameters

  • device:

    The USB device to detach.

  • completionHandler:

    A block the framework calls after the device detaches, or on an error. The error parameter that passes to the block is nil if detaching the device is successful. The framework calls the block on a VM’s queue.

Discussion

If the device successfully detaches from the controller, it disappears from the usbDevices property, the framework sets its usbController property to nil, and the completion handler returns nil.

If the device doesn’t have an attachment to the controller at the time of calling the detach method, the process fails with VZError.Code.deviceNotFound.

You need to call this method on the virtual machine’s queue.

See Also

Related Documentation

Attaching and detaching devices