<!--
{
  "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/init(upgradeFor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Network Extension"
    ],
    "preciseIdentifier" : "c:objc(cs)NWTCPConnection(im)initWithUpgradeForConnection:"
  },
  "title" : "init(upgradeFor:)"
}
-->

# init(upgradeFor:)

This convenience initializer can be used to create a new connection that will only be connected if there exists a better path (as determined by the system) to the remote endpoint of the original connection.

```
init(upgradeFor connection: NWTCPConnection)
```

## Discussion

An upgraded connection will be initialized using the same remote endpoint and set of parameters from the original connection. If the original connection becomes disconnected or cancelled, the new upgrade connection will automatically be considered better.

The caller should create an [`NWTCPConnection`](/documentation/NetworkExtension/NWTCPConnection) and watch for the `hasBetterPath` property. When this property is <doc://com.apple.documentation/documentation/Swift/true>, the caller should attempt to create a new upgrade connection, with the goal to start transferring data on the new connection path as soon as possible to reduce power and avoid expensive networks. When the new connection is successfully connected the caller can start using the new connection and cancel the original one.

---

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)