Instance Property


A Boolean value that indicates whether connections may use a network interface that the system considers expensive.


var allowsExpensiveNetworkAccess: Bool { get set }


The system determines what constitutes “expensive” based on the nature of the network interface and other factors. iOS 13 considers most cellular networks and personal hotspots expensive. If there are no nonexpensive network interfaces available and the request’s allowsExpensiveNetworkAccess property is false, any task created from the request fails. In this case, the error provided when the task fails has a networkUnavailableReason property whose value is NSURLErrorNetworkUnavailableReason.expensive.

Setting this property on a request overrides the allowsExpensiveNetworkAccess property of URLSessionConfiguration. For example, if the session configuration’s allowsExpensiveNetworkAccess value is false, and you create a task from a request whose allowsExpensiveNetworkAccess is true, the task treats the value as true.

Limit your app’s of use of expensive network access to user-initiated tasks, and put off discretionary tasks until a nonexpensive interface becomes available.

See Also

Supporting Limited Modes

var allowsConstrainedNetworkAccess: Bool

A Boolean value that indicates whether the request may use the network when the user has specified Low Data Mode.