<!--
{
  "availability" : [
    "iOS: 7.0.0 - 27.0.0",
    "iPadOS: 7.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.10.0 - 27.0.0",
    "tvOS: 10.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MultipeerConnectivity",
  "identifier" : "/documentation/MultipeerConnectivity/MCSessionDelegate/session(_:peer:didChange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Multipeer Connectivity"
    ],
    "preciseIdentifier" : "c:objc(pl)MCSessionDelegate(im)session:peer:didChangeState:"
  },
  "title" : "session(_:peer:didChange:)"
}
-->

# session(_:peer:didChange:)

Called when the state of a nearby peer changes.

```
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

This delegate method is called with the following state values when the nearby peer’s state changes:

- [`MCSessionState.connected`](/documentation/MultipeerConnectivity/MCSessionState/connected)—the nearby peer accepted the invitation and is now connected to the session.
- [`MCSessionState.notConnected`](/documentation/MultipeerConnectivity/MCSessionState/notConnected)—the nearby peer declined the invitation, the connection could not be established, or a previously connected peer is no longer connected.

---

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)