---
title: "connect(to:timeout:callback:)"
framework: Playground Bluetooth
role: symbol
role_heading: Instance Method
platforms: [xcode 10.2+, swift playgrounds 2.0+]
path: playgroundbluetooth/playgroundbluetoothcentralmanager/3029464-connect
---

# connect(to:timeout:callback:)

Attempts to connect the central manager to the specified peripheral.

## Declaration

```swift
func connect(to peripheral: CBPeripheral, timeout: TimeInterval? = nil, callback: ((CBPeripheral, Error?) -> Void)? = nil)
```

## Parameters

- `peripheral`: The peripheral to attempt to connect to.
- `timeout`: The amount of time, in seconds, before the connection attempt is aborted. If the timeout value is nil, the attempt won’t time out. To cancel a connection attempt, call the doc://com.apple.documentation/documentation/playgroundbluetooth/playgroundbluetoothcentralmanager/3029469-disconnect method.
- `callback`: A function that’s called when the connection attempt succeeds or fails.

## See Also

### Connecting Peripherals

- [connect(toPeripheralWithUUID:timeout:callback:)](playgroundbluetooth/playgroundbluetoothcentralmanager/3029465-connect.md)
- [connectToLastConnectedPeripheral(timeout:callback:)](playgroundbluetooth/playgroundbluetoothcentralmanager/3029466-connecttolastconnectedperipheral.md)
- [PlaygroundBluetoothCentralManager.ConnectionError](playgroundbluetooth/playgroundbluetoothcentralmanager/connectionerror.md)
