iPhone : Browse documents - iphone

I have searched a little about file browsing on iPhone and i'd like to confirm some of my conclusions :
an App can't browse files outside its sandbox. Examples : no app can browse the files inside 'iBooks','voice Memos', 'Notes' ..etc. One exception however: the 'Photos' app sandbox is browsable through UIImagePickerController.
browsing an app's directory from itunes is possible if File-Sharing is enabled (UIFileSharingEnabled).
Thanks in advance for your replies.

Correct. :) Easiest response ever!
Well, to clarify, the directory browsable in iTunes with UIFileSharingEnabled is specifically your app's ~/Documents directory. (You can make use of other directories with particular functionality, like ~/Library/Caches, which is ignored by iCloud backups and subject to deletion when the device is low on storage.)

Related

iOS - How to locate all files on my IPad/IPhone through Objective-C

I am writing an App that will allow users to browse through all files of a certain extension (say PDF, XLS) on my IPhone/IPad. The App will then upload the file to a server.
The App should be able to locate files which are not located in its sandbox directories.
How can this be done in Objective-C?
Thanks a lot.
This is not possible. Your app cannot access files or directories outside of its sandbox.
You can enable users to open documents from other applications into your application and then send them to the server. In the application, you must specify what type of documents you want to open (UTI).
You can't do this. Your app can only access files inside its sandbox directory unless the device is jailbroken. If your app even attempts to read files outside of the sandbox, it will be rejected from the App Store.

Transfer file from Mac/PC to iPhone App Document folder

I want to transfer file from system (mac/Pc), which is present on my iPhone wifi network, to the document folder of my iPhone App.The scenario of my App is this, it will browse the system which are present in it's network. select any file(such as .pdf or ,docx) from that system(mac/Pc), copy it into the document folder of the APP and than use it with in the APP.During my search i come across the link iPhone : Transfer of files from Mac/Pc to app i have not found the detail instruction document, how to use it. Is Apple support any API or farm work to do this ? Please guide me
This is called iTunes file sharing. In the most simple way, you simply set the UIFileSharingEnabled key in your Info.plist file to YES. See for example this tutorial.
Rewriting itunes is not a simple task but I recommend you a clever and easier solution:
Implement a simple webserver on your iOS app. Write a windows application which will connect to your iOS app through wifi network. Then transfer the necessary files this way: you will send a file to you app, then your app should save it in documents directory.

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

Downloading files for UIWebView to specific folder on IPhone

I have made an app that displays my website from a UIWebView and it takes you to a store that you can download files. My question is that I need to download a '.zip'file from my website using the app to the IPhone. Heres is my problem. I don't want the file to goto the App's Document folder, I want it to goto a folder that is outside of my applications folder. Here is an example path I might want my file to goto EX:'var/mobile/Library/Downloads'. If there is not a way to download the files to a path outside of the app's folder, is there a way to transfer the specific file that I have downloaded from my website using the my app to another folder that is not located in my app's folders? I know this can be done because I have used apps that have done this, of course they were apps only available on Cydia. This is also an app that will be used for Jail-broken users just for your information!
Thanks for any help!
Any "regular" iphone app runs in a sandbox that prevents access to system wide directories. Practically, you only have access to the app Home Directory.
Unless you go for a jailbroken app, you have no other options than storing to the App docs folder.
Read "The Application Sandbox" and "The File System" [here] for more details1.
EDIT:
I am not an expert on cydia, but the general idea is gaining access as root and then write to where you need to. This can be done by replacing your app with a suid shell script that will in turn exec your app (which will have root privileges now and then be able to go out of the sandbox).
For more info look at this.

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