<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AccessoryAccess",
  "identifier" : "/documentation/AccessoryAccess/AAUSBAccessory",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Accessory Access"
    ],
    "preciseIdentifier" : "c:objc(cs)AAUSBAccessory"
  },
  "title" : "AAUSBAccessory"
}
-->

# AAUSBAccessory

A class that represents a USB accessory.

```
class AAUSBAccessory
```

## Discussion

A USB accessory can either be obtained from the [`usbAccessoryDidConnect(_:)`](/documentation/AccessoryAccess/AAUSBAccessoryListener/usbAccessoryDidConnect(_:)) method, or instantiated from an <doc://com.apple.documentation/documentation/XPC> representation that describes an existing USB accessory.

## Topics

### Creating USB accessories

[`init?(XPCRepresentation: xpc_object_t)`](/documentation/AccessoryAccess/AAUSBAccessory/init(XPCRepresentation:)-5lxcr)

Creates a USB accessory from an XPC representation.

[`init?(xpcRepresentation: xpc_object_t)`](/documentation/AccessoryAccess/AAUSBAccessory/init(xpcRepresentation:)-6dmbu)

Creates a USB accessory from an XPC representation.

[`init?(coder: NSCoder)`](/documentation/AccessoryAccess/AAUSBAccessory/init(coder:))

Creates a new USB accessory with the provided coder.

### Getting information about a USB accessory

[`var configurationDescriptorData: Data?`](/documentation/AccessoryAccess/AAUSBAccessory/configurationDescriptorData)

Returns the currently selected configuration descriptor data.

[`var deviceDescriptorData: Data`](/documentation/AccessoryAccess/AAUSBAccessory/deviceDescriptorData)

Returns the device descriptor data.

[`var registryID: UInt64`](/documentation/AccessoryAccess/AAUSBAccessory/registryID)

Returns the IORegistry ID for the USB accessory.

### Managing a USB accessory

[`func open(serviceQueue: dispatch_queue_t?, completionHandler: (IOUSBHostDevice, (any Error)?) -> Void)`](/documentation/AccessoryAccess/AAUSBAccessory/open(serviceQueue:completionHandler:))

Opens a connection to the USB accessory for this process to access it exclusively.

[`func close(completionHandler: ((any Error)?) -> Void)`](/documentation/AccessoryAccess/AAUSBAccessory/close(completionHandler:))

Closes all connections to the USB accessory for this process.

### Connection and disconnection events

[`enum Event`](/documentation/AccessoryAccess/AAUSBAccessory/Event)

Events that represent accessory connection and disconnection.

### Encoding a USB accessory for delivery to an XPC service

[`func createXPCRepresentation() -> xpc_object_t`](/documentation/AccessoryAccess/AAUSBAccessory/createXPCRepresentation())

Creates an encoded representation of the USB accessory.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Hashable`](/documentation/Swift/Hashable)

[`Sendable`](/documentation/Swift/Sendable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)