Call an IOUSBDeviceInterface function on an obj-c object instead of a C structure

Posted by b1onic on Stack Overflow See other posts from Stack Overflow or by b1onic
Published on 2012-07-11T02:28:59Z Indexed on 2012/07/11 3:15 UTC
Read the original article Hit count: 300

Filed under:
|
|
|

Let's say I want to close an USB device. Here is a C structure representing the USB device:

struct __USBDevice {

uint16_t idProduct;
io_service_t usbService;
IOUSBDeviceInterface **deviceHandle;
IOUSBInterfaceInterface **interfaceHandle;
Boolean open;

};

typedef struct __USBDevice *USBDeviceRef;

Here is the code to close the device:

// device is a USBDeviceRef structure
// USBDeviceClose is a function member of IOUSBDeviceInterface C Pseudoclass

(*device->deviceHandle)->USBDeviceClose(device->deviceHandle);

Now imagine that the device properties are declared in an obj-c class

@interface Device : NSObject {

NSNumber idProduct
io_service_t usbService;
IOUSBDeviceInterface **deviceHandle;
IOUSBInterfaceInterface **interfaceHandle;
BOOL open;
}

@end

How would I do to call USBDeviceClose() ?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about c