---
title: "connect(replyHandler:)"
framework: gamecontroller
role: symbol
role_heading: Instance Method
path: "gamecontroller/gcvirtualcontroller/connect(replyhandler:)"
---

# connect(replyHandler:)

Connects the virtual controller to the device and displays it on the screen.

## Declaration

```swift
func connect(replyHandler reply: (@Sendable ((any Error)?) -> Void)? = nil)
```

```swift
func connect() async throws
```

## Parameters

- `reply`: A closure that the method calls upon completion with the following parameter:

## Mentioned in

Adding virtual controls to games that support game controllers in iOS

## Discussion

Discussion After you invoke this method, the framework calls any input handlers you set for the elements, or you can poll the elements for their values.

## See Also

### Connecting and displaying virtual controllers

- [disconnect()](gamecontroller/gcvirtualcontroller/disconnect().md)
