Instance Property インスタンスプロパティ

allowsExpensiveNetworkAccess

A Boolean value that indicates whether connections may use a network interface that the system considers expensive. システムが高くつくと考えるネットワークインターフェイスを接続が使うかもしれないかどうかを指し示すブール値。

Declaration 宣言

var allowsExpensiveNetworkAccess: Bool { get set }

Discussion 議論

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 session’s allowsExpensiveNetworkAccess property is false, any task created from the session fails. In this case, the error provided when the task fails has a networkUnavailableReason property whose value is NSURLErrorNetworkUnavailableReason.expensive. システムは、何が “高くつく” ことを構成するかを、ネットワークインターフェイスと他の要因の本質に基づいて決定します。iOS 13は、ほとんどのセルラーネットワークと個人のホットスポットを高くつくと考えます。利用可能な高くつかないネットワークインターフェイスがないそしてセッションのもつallowsExpensiveNetworkAccessプロパティがfalseならば、セッションから作成されたあらゆるタスクは失敗します。この場合には、タスクが失敗する時に提供されたエラーは、networkUnavailableReasonプロパティを持ちます、それの値はNSURLErrorNetworkUnavailableReason.expensiveです。

Limit your app’s of use of expensive network access to user-initiated tasks, and put off discretionary tasks until an nonexpensive interface becomes available. To do this, set allowsExpensiveNetworkAccess (and allowsConstrainedNetworkAccess) to false and waitsForConnectivity to true. This way, your URLSessionTask waits for a suitable interface to become available before sending or receiving data. 高くつくネットワークアクセスのあなたのアプリの利用をユーザ着手のタスクに制限してください、そして高くつかないインターフェイスが利用可能になるまで自由裁量のタスクを延期してください。これをするには、allowsExpensiveNetworkAccess(そしてallowsConstrainedNetworkAccessfalseに、そしてwaitsForConnectivitytrueに設定してください。こうして、あなたのURLSessionTaskは、データの送信または受信の前に適切なインターフェイスが利用可能になるのを待ちます。

See Also 参照

Supporting Limited Modes 制限モードをサポートする