which directory should i use for files not available for users? - swift

I have an app for ipad and iphone and since users can download files in there i've enabled UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace in my plist, so users can find the files. (I store them in FileManager.default.url(for:.documentsDirectory,...))
However the app also needs to write texts to files, that shouldn't be accessable for the users. Where should i store those?

Related

How can I copy files to Documents folder of my app through iTunes

I saw some apps like GoodReader have this function.
User can copy their documents to a folder of app through iTunes and then use them in app.
What can I do to perform this function.
Thanks!
UIFileSharingEnabled
UIFileSharingEnabled (Boolean - iOS) specifies whether the application shares files through iTunes. If this key is YES, the application shares files. If it is not present or is NO, the application does not share files. Applications must put any files they want to share with the user in their /Documents directory, where is the path to the application’s home directory.
In iTunes, the user can access an application’s shared files from the File Sharing section of the Apps tab for the selected device. From this tab, users can add and remove files from the directory.
This key is supported in iOS 3.2 and later.
from: http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html
You have to set UIFileSharingEnabled key in the info plist of your app.

Iphone app to be used like usb storage.

I'm wanting to access applications storage via iTunes, where i can save documents and be available in my app.
I have looked all over google, but without a specific name i don't know what I'm looking for.
Some of the app's that use this functionality are VLC & usb Disk; there are many many more.
So I'm asking what the API is called and if anyone knows of sample code or an example.
Essentially, all you have to do is add a boolean UIFileSharingEnabled (YES) key to your app's info.plist. Then the documents added through iTunes will be available in your app's documents directory.
UIFileSharingEnabled (Boolean - iOS) specifies whether the application
shares files through iTunes. If this key is YES, the application
shares files. If it is not present or is NO, the application does not
share files. Applications must put any files they want to share with
the user in their /Documents directory, where
is the path to the application’s home directory.
In iTunes, the user can access an application’s shared files from the
File Sharing section of the Apps tab for the selected device. From
this tab, users can add and remove files from the directory.
This key is supported in iOS 3.2 and later.
Apple's sample code: DocInteraction

How to protect personal documents in my app for the maximum

I want to protect the user's document downloaded via my app.
- If I store the files in Document folder of iOS, iTunes will read them, right?
- If I store the files in Library or a subdirectory of it, files will be cleaned when the app is upgraded?
- The NSFileManager has a NSFileProtectionKey property. But I'm not sure what exactly it can do to protect the files? Does it can prevent other app from reading the user's files?
Overall, I want the files only can be read in my application, other than iTunes or other jailbreak app.
Thanks alot.
Every app is in a SandBox. It means other apps can't access your app files, even from low-level functions.
So they are quite secure.
You can actually see this with this little app, available from the AppStore:
http://www.eosgarden.com/en/freeware/filesystem/
Apps are located in /var/mobile

iphone transferring files using iTunes, but not allowing user to see all of docs directory?

It doesn't sound like this is possible, but I will ask anyway.
In my app, I store a lot of images and plists in the documents directory.
I would like to implement a PDF reader in the app that allows users to load their PDFs into the app via iTunes. I do not want the user to be able to see/access the contents of the documents directory since they could cause the app to perform unexpectedly if they messed with these files.
Is this possible, or is it possible to place my plists and images somewhere else?
You'll need to be registered with Apple to see this, but this page should give you the information you need.
You'll need to add a UIFileSharingEnabled key to Info.plist. This will give the user access to the Documents directory of the app, and let them remove or add files.
This tutorial gives an example of how to set up PDF support in an iPad app.

iTunes Documents Directory in my app

how can I setup my app to accept documents via iTunes, like the Air Sharing or VLC app?
I mean, I want to allow users to get content from the app using iTunes.
Anyone know how?
Thanks
Copied from http://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS3_2.html#//apple_ref/doc/uid/TP40009337-SW11.
To enable file sharing for your application, do the following:
Add the UIFileSharingEnabled key to your application’s Info.plist file and set the value of the key to YES.
Put whatever files you want to share in your application’s Documents directory.
When the device is plugged into the user’s computer, iTunes displays a File Sharing section in the Apps tab of the selected device.
The user can add files to this directory or move files to the desktop.