假设我想关闭一个 USB 设备。这是一个代表 USB 设备的 C 结构:
struct __USBDevice {
uint16_t idProduct;
io_service_t usbService;
IOUSBDeviceInterface **deviceHandle;
IOUSBInterfaceInterface **interfaceHandle;
Boolean open;
};
typedef struct __USBDevice *USBDeviceRef;
这是关闭设备的代码:
// device is a USBDeviceRef structure
// USBDeviceClose is a function member of IOUSBDeviceInterface C Pseudoclass
(*device->deviceHandle)->USBDeviceClose(device->deviceHandle);
现在假设设备属性在 obj-c 类中声明
@interface Device : NSObject {
NSNumber idProduct
io_service_t usbService;
IOUSBDeviceInterface **deviceHandle;
IOUSBInterfaceInterface **interfaceHandle;
BOOL open;
}
@end
我将如何调用 USBDeviceClose() ?