<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ExternalAccessory",
  "identifier" : "/documentation/ExternalAccessory/EASession/init(accessory:forProtocol:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "External Accessory"
    ],
    "preciseIdentifier" : "c:objc(cs)EASession(im)initWithAccessory:forProtocol:"
  },
  "title" : "init(accessory:forProtocol:)"
}
-->

# init(accessory:forProtocol:)

Initializes the session for the specified accessory and protocol.

```
init?(accessory: EAAccessory, forProtocol protocolString: String)
```

## Parameters

`accessory`

The accessory with which you want to communicate. You can get a list of accessory objects from the [`EAAccessoryManager`](/documentation/ExternalAccessory/EAAccessoryManager) object.

`protocolString`

The protocol to use when communicating with the accessory. This protocol must be one that the accessory understands. All communications with the accessory are expected to use this protocol.

## Return Value

The initialized session object. This method may return `nil` if the accessory does not recognize the specified protocol or there was an error communicating with the accessory.

## Discussion

There can be only one session object at a time for a given accessory and protocol combination.

---

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)