A Boolean value that indicates whether the session should wait for connectivity to become available, or fail immediately.
SDKs
- iOS 11.0+
- macOS 10.13+
- Mac Catalyst 13.0+
- tvOS 11.0+
- watchOS 4.0+
Framework
- Foundation
Declaration
var waitsForConnectivity: Bool { get set }
Discussion
Connectivity might be temporarily unavailable for several reasons. For example, a device might only have a cellular connection when allows
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 url
method of URLSession
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 NSURLError
.
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 NSURLError
. 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.