---
title: "init(accessory:forProtocol:)"
framework: externalaccessory
role: symbol
role_heading: Initializer
path: "externalaccessory/easession/init(accessory:forprotocol:)"
---

# init(accessory:forProtocol:)

Initializes the session for the specified accessory and protocol.

## Declaration

```swift
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 doc://com.apple.externalaccessory/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

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

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