---
title: "peers(with:)"
framework: gamekit
role: symbol
role_heading: Instance Method
path: "gamekit/gksession/peers(with:)"
---

# peers(with:)

Returns a list of peers in the specified connection state.

## Declaration

```swift
func peers(with state: GKPeerConnectionState) -> [Any]!
```

## Parameters

- `state`: The connection state to search for. See doc://com.apple.gamekit/documentation/GameKit/GKPeerConnectionState for possible values.

## Return Value

Return Value An array of NSString objects with a peerID string for each peer visible to the session that is currently in the specified connection state. If there are no peers in the specified connection state, this method returns nil.

## See Also

### Obtaining Information About Other Peers

- [displayName(forPeer:)](gamekit/gksession/displayname(forpeer:).md)
