This convenience initializer can be used to create a new connection that wil 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)


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 and watch for the hasBetterPath property. When this property is 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.

See Also

Responding to Network Changes

var hasBetterPath: Bool

If a connection has a better path, new connections would use a different interface

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software