Reputation: 1144
I am trying to allow the user to download a file.
When the file is downloaded it is displayed in the browser window instead of downloading it.
Does anyone know of a way to get the iPhone to download files instead of viewing them.
Also all the code that I have tried works great on Android Devices.
Thanks.
Upvotes: 1
Views: 2902
Reputation: 131471
Are you writing a program that downloads an image, or trying to do this as a user?
If you're writing a program, you can only download files to a limited number of locations. Your app's documents directory is the most obvious choice.
You will need to create an NSURLRequest, and then an NSURLConnection, and then implement a number of delegate methods to handle the incoming data. Then you'll need to use NSFileManager methods to write the data to a file.
Upvotes: 1
Reputation: 833
You can't. Apple have deliberately prevented things like this to protect their iOS from hacks and malware; you have no access (unless you are a developer, in which case its restricted) to the handsets integrated data storage.
Upvotes: 6