Called when the state of a nearby peer changes.
Required.
SDKs
- iOS 7.0+
- macOS 10.10+
- Mac Catalyst 13.0+
- tvOS 10.0+
Framework
- Multipeer
Connectivity
Declaration
func session(_ session: MCSession, peer peerID: MCPeer ID, didChange state: MCSession State)
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:
MCSession
—the nearby peer accepted the invitation and is now connected to the session.State .connected MCSession
—the nearby peer declined the invitation, the connection could not be established, or a previously connected peer is no longer connected.State .not Connected