Contents

waitsForConnectivity

A Boolean value that indicates whether the session should wait for connectivity to become available, or fail immediately.

Declaration

var waitsForConnectivity: Bool { get set }

Mentioned in

Discussion

Connectivity might be temporarily unavailable for several reasons. For example, a device might only have a cellular connection when allowsCellularAccess is set to false, or the device might require a VPN connection but none is available. If the value of this property is true and sufficient connectivity is unavailable, the session calls the urlSession(_:taskIsWaitingForConnectivity:) method of URLSessionTaskDelegate and waits for connectivity. When connectivity becomes available, the task begins its work and ultimately calls the delegate or completion handler as usual.

If the value of the property is false and connectivity is unavailable, the connection fails immediately with an error, such as NSURLErrorNotConnectedToInternet.

This property is relevant only during the establishment of a connection. If a connection is established and then drops, the completion handler or delegate receives an error, such as NSURLErrorNetworkConnectionLost. For help dealing with dropped connections, see Handling “The network connection was lost” Errors.

This property is ignored by background sessions, which always wait for connectivity.

See Also

Setting general properties