假設我想關閉USB設備。這裏是表示USB設備C結構:在obj-c對象上調用IOUSBDeviceInterface函數而不是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()?
您能否提供第一種方式的快速代碼示例?謝謝。 – b1onic 2012-07-11 02:45:17
我已經做了,只需在所有的iVar上添加'@ public'即可。然後你可以像這樣訪問它們'device-> idProduct'等 – borrrden 2012-07-11 02:48:52
哦,我想出了謝謝。 – b1onic 2012-07-11 02:50:52