---
title: "session(_:peer:didChange:)"
framework: multipeerconnectivity
role: symbol
role_heading: Instance Method
path: "multipeerconnectivity/mcsessiondelegate/session(_:peer:didchange:)"
---

# session(_:peer:didChange:)

Called when the state of a nearby peer changes.

## Declaration

```swift
func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState)
```

## Parameters

- `session`: The session that manages the nearby peer whose state changed.
- `peerID`: The ID of the nearby peer whose state changed.
- `state`: The new state of the nearby peer.

## Discussion

Discussion This delegate method is called with the following state values when the nearby peer’s state changes: MCSessionState.connected—the nearby peer accepted the invitation and is now connected to the session. MCSessionState.notConnected—the nearby peer declined the invitation, the connection could not be established, or a previously connected peer is no longer connected.

## See Also

### MCSession Delegate Methods

- [session(_:didReceive:fromPeer:)](multipeerconnectivity/mcsessiondelegate/session(_:didreceive:frompeer:).md)
- [session(_:didStartReceivingResourceWithName:fromPeer:with:)](multipeerconnectivity/mcsessiondelegate/session(_:didstartreceivingresourcewithname:frompeer:with:).md)
- [session(_:didFinishReceivingResourceWithName:fromPeer:at:withError:)](multipeerconnectivity/mcsessiondelegate/session(_:didfinishreceivingresourcewithname:frompeer:at:witherror:).md)
- [session(_:didReceive:withName:fromPeer:)](multipeerconnectivity/mcsessiondelegate/session(_:didreceive:withname:frompeer:).md)
- [session(_:didReceiveCertificate:fromPeer:certificateHandler:)](multipeerconnectivity/mcsessiondelegate/session(_:didreceivecertificate:frompeer:certificatehandler:).md)
