How to make a network request wait for an internet connection

Опубликовано: 15 Октябрь 2024
на канале: Swift++
115
9

Set to true waitsForConnectivity property to make network requests wait for a viable internet connection before starting. This is useful in scenarios with intermittent connectivity. timeoutIntervalForResource specifies the maximum time (in seconds) a resource request should take, once it begins. In our example, we set it to 300 seconds, ensuring that downloads don't drag on indefinitely once they've started.