Reputation: 209
I got a question: How I understand this:
"iOS Note: The NSURLDownload class is not available in iOS, because downloading directly to the file system is discouraged. Use the NSURLConnection class instead. See “Using NSURLConnection” for more information."
there is no possibility to store a download directly in the Filesystem. But if I use "NSURLConnection" instead and download a file(lets say it is like 500MB) does it store in the RAM or somewhere else in like a Temp-Folder in the Storage-System?
If it stores in the RAM, is it possible to anyway save it directly to the disk?
Thanks
Upvotes: 2
Views: 1504
Reputation: 19030
What this means is that it's discouraged to download directly to a file on the filesystem, a convention common to desktop computers, but rarely seen on iOS.
The data will not always be stored in RAM, the size of the file will probably far outweigh the amount of RAM available on the device, as it's fairly limited. The response from a NSURLConnection
will be stored in the cache; it's still written to disk, but the OS keeps track of it, not your application. Because this is an OS implementation detail, which application developers should not be concerned with, there's no guarantee where this data will be stored, and hence try not to access it directly via the filesystem.
You can of course save the data to disk, under your control, once you receive the data from NSURLConnection
. To do so, set up your NSURLConnection
using this guide. The important thing is to set up your NSURLConnectionDelegate
correctly. See this documentation regarding the protocol.
The method you're interested in is this one (which is a required method anyway!)
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
Once you have the NSData
available to you, you can do as you wish with it. You save save this data to disk, see the documentation on NSData on how to do this.
Upvotes: 1