<!--
{
  "availability" : [
    "iOS: 9.0.0 - 18.0.0",
    "iPadOS: 9.0.0 - 18.0.0",
    "macCatalyst: 13.1.0 - 18.0.0",
    "macOS: 10.11.0 - 15.0.0",
    "tvOS: 17.0.0 - 18.0.0",
    "visionOS: 1.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "NetworkExtension",
  "identifier" : "/documentation/NetworkExtension/NWTCPConnection/state",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Network Extension"
    ],
    "preciseIdentifier" : "c:objc(cs)NWTCPConnection(py)state"
  },
  "title" : "state"
}
-->

# state

The status of the connection.

```
var state: NWTCPConnectionState { get }
```

## Discussion

Use Key-Value Observing (KVO) to monitor the state. Many methods, such as reading and writing on the connection, are only valid when the state is `NWTCPConnectionStateConnected`. For information about KVO, see [Key-Value Observing Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html#//apple_ref/doc/uid/10000177i).

---

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)