---
title: "cancelConnect(toPeer:)"
framework: gamekit
role: symbol
role_heading: Instance Method
path: "gamekit/gksession/cancelconnect(topeer:)"
---

# cancelConnect(toPeer:)

Cancels a pending request to connect to another iOS device.

## Declaration

```swift
func cancelConnect(toPeer peerID: String!)
```

## Parameters

- `peerID`: The string identifying the peer you previously requested to connect to.

## Discussion

Discussion Your application previously called connect(toPeer:withTimeout:) to create a connection to another iOS device. When your application cancels the connection attempt, both delegates’ session(_:connectionWithPeerFailed:withError:) methods are called. If your application already connected to the peer, your application should call disconnectFromAllPeers() instead.

## See Also

### Connecting to a Remote Peer

- [connect(toPeer:withTimeout:)](gamekit/gksession/connect(topeer:withtimeout:).md)
