Search code examples
iosswiftfilensurldownload

Protect downloaded files


I'm making an application that downloads external files (images and documents) using NSURLDownlod.

But I need to keep this files protected.

If the user downloads some file using NRURLDownload, this file cannot be accessible to in another place. For example, if he plugs his ipad on macbook, we wont find this downloaded file.

In another words, they can be only accessible into his application.

Is there any way to do that?


Solution

  • The simplest thing you can do is save the file with the NSData method: writeToFile:options:error: and one of the NSDataWritingOptions such as NSDataWritingFileProtectionComplete.

    See the Apple documentation for full details.