Is there any speed difference in download speed when app is in background.I am using NSURLSession to download a set of files in background.Also can we restrict the downloads of items to one because when i checked the sample,3 files are getting downloaded.Any ideas?
1 Answers
Yes, there may be a speed difference with background transfers. It's difficult to know what that speed difference will be. Once your app is in the background, the NSURLSession background daemon will manage the download to maximise efficiency, depending on several factors, including other data transfers, the network state (Wi-Fi or cellular, say) and the available battery life of the device.
If you watch the WWDC 2013 session 705 video, "What's New In Foundation Networking", you'll find that covered briefly around 33 minutes in, in the "Background Transfers" section. (That's a section well worth watching if you're interested in background transfers. It includes a full worked example of an app that does a background download.)
Foreground transfers are likely to be faster (as by keeping the app in the foreground, you're effectively hinting to iOS that its associated network transfers are more important to you than anything else that might be going on.)
To restrict the number of concurrent transfers, you probably want to look into the HTTPMaximumConnectionsPerHost
property of NSURLSessionConfiguration
. There's an example of setting that in the Ray Wenderlich NSURLSession tutorial.

- 37,886
- 9
- 99
- 128
-
Can i manually assign an order in which the download can be initiated like keeping the downloaded list in an array and downloading the content one by one. – Jacob Davis Cherussery Apr 21 '14 at 13:58
-
You should ask that as a new question -- Stack Overflow works best with one question per post. (But I'd *guess* that if you're only dealing with one server, then using the HTTPMaximumConnectionsPerHost configuration option would probably queue the tasks in the order they were added.) – Matt Gibson Apr 21 '14 at 14:20
-
Yes I'm dealing with only one server.But when i tried to access the library folder inside application which consists of the current downloads often 3 items are getting downloaded. – Jacob Davis Cherussery Apr 22 '14 at 04:33