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 throwsParameters
- 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
nilif 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.