Contents

cancelConnectPeer(_:)

Cancels an attempt to connect to a peer.

Declaration

func cancelConnectPeer(_ peerID: MCPeerID)

Parameters

  • peerID:

    The ID of the nearby peer.

Discussion

Call this method to cancel connections to peers when you are using your own service discovery code instead of an MCNearbyServiceBrowser or MCBrowserViewController object. It should be called in two situations:

  • If your app calls connectPeer(_:withNearbyConnectionData:) and later needs to cancel the connection attempt

  • If your app has obtained nearby connection data for a peer but you decide not to connect to the peer

For more information, see the Managing Peers Manually section in the overview of the MCSession class reference.

See Also

Managing Peers Manually