I have an app with Tab Bar.
Each Tab starts to request some data from the Internet using NSURLConnection way once is loaded.
Everything works fine, but if I switch tab when data is still loading, then the first request is “queued” to the second one and I found my data duplicated.
How can I suspend the download of the data when the user switches tabs?
I have an app with Tab Bar. Each Tab starts to request some data
Share
There is no direct built-in support to pause an
NSURLConnection. Instead, you need to:It’s best to check that the data on the server hasn’t changed in the meantime too, and that data in step 4 is the bit of file you requested.
Alternatively, it may be enough to unschedule the connection from the runloop. This should make it resumable (by rescheduling) within a small timeframe, but will fail if left too long.