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

# init(upgradeFor:)

This convenience initializer can be used to create a new session based on the original session’s endpoint and parameters.

```
init(upgradeFor session: NWUDPSession)
```

## Discussion

The caller should watch the `hasBetterPath` property on an existing [`NWUDPSession`](/documentation/NetworkExtension/NWUDPSession) object. When `hasBetterPath` is <doc://com.apple.documentation/documentation/Swift/true>, the caller should call `initWithUpgradeForSession:` to create a new session, then start transferring data on the new session as soon as possible to reduce power and and avoid expensive networks. When the new session is ready, the application can start using the new session and tear down 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)