<!--
{
  "availability" : [
    "iOS: 3.0.0 - 7.0.0",
    "iPadOS: 3.0.0 - 7.0.0",
    "macOS: 10.8.0 - 10.10.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 3.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "GameKit",
  "identifier" : "/documentation/GameKit/GKSession/peers(with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKSession(im)peersWithConnectionState:"
  },
  "title" : "peers(with:)"
}
-->

# peers(with:)

Returns a list of peers in the specified connection state.

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

## Parameters

`state`

The connection state to search for. See [`GKPeerConnectionState`](/documentation/GameKit/GKPeerConnectionState) for possible values.

## Return Value

An array of <doc://com.apple.documentation/documentation/Foundation/NSString> objects with a [`peerID`](/documentation/GameKit/GKSession/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`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)