Storing & Reading documents present in iCloud - ios

i want to develop an iPad app where i can store a list of PDF files/ iWork files in iCloud.
Finally any user who is using this app can able to download & read(only read no write) these documents inside my App.
Also i want to enable the autosync functionality in my app .So user can see updated document always.
Is this Possible ? What is the right way to achieve this functionality ?

Related

Add a file into the ios app

I am a newbie to iOS, I have a created a textfield and imageView in a ViewController. I want user of app to select an image or a file(.txt,.csv, etc)into the App. I know that Apple provides UIImagePicker to select images from the device. with these I added an image to my imageView.
Now I want to Know that is there any way to select files from the device and use it into application. Or else Open file system of device and select the file ?
When I Googled it, I got that you are not able to open the file system. So how can I implement this functionality in iOS app?
There is no way of selecting file from file system into application. You can only access files from
Default Photos App
Application Documents Directory
Any file from web server with use of API's
There are multiple ways from which you can select files of different types other than images are
Integrate Dropbox SDK into app
Integrate Google Drive
Integrate iCloud
So create one UIButton like "Select File" and open UIActionSheet on tap of it. UIActionSheet will have options like
Select From Photos
Select File From Dropbox
Select File From iCloud
Select File From Google Drive
etc
And you can call respective actions on each index.
You can pick your documents and images and other files by using separator picker for each like
for Documents - UIDocumentPickerViewController
for Images/Videos - UIImagePickerController
Apple does not provide a direct picker for all files.
Hope this is working for you. :)
You can use UIDocumentPickerViewController if you enable iCloud document support for your app.
you can not load files directly from file system, but you can load them from some third party applications like Documents and cloud sources like iCloud and Drop Box with UIDocumentPickerViewController

Can a PDF downloaded by my iOS app be viewed by iBooks or any other application?

Right now, the PDFs I download on my app are being stored in the app's document directory and can be retrieved only within the app. Is there any way to store the PDF files in the common documents directory that can be accessed by other apps?
If not, is there a way of storing my downloaded PDFs in other apps' documents directory (let's say iBooks), so that it will always be stored in iBooks.
If there are any ways, please elaborate.
There is no "commun documents directory" on iOS, each App is launched in is own sandbox and cannot access the files from other app directly.
I suggest you to check the iOS File System Basics guide from Apple in order to understand better what's happening behind the scenes.
You can still use an UIActivityController in your code to perform an export of your pdf file to iBooks or any app accepting this kind of file, but it requires some user interaction.

How to pick(picker view) any files from ios device using objective c?

I was developing an ios application for file backup. In that I need to list and enable user to pick up files from any folder and need to do email backup like media and image picker.
I am struckup here with a bottle neck. I can't triger populating the list of document and email list for the user to pick. I had tried many codes, but it is not working.
I was working with the simulator.
Could anyone share their insight?
Regards
You should be more precise : do you want to pick up any file from any application on your device or just in your application library folder ? You can't access others applications folders.
You can find more information about the file system here :
https://developer.apple.com/library/mac/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
iPhone do not have a file browser.
The only place that a iPhone app can take file is from photo album.
Every application keeps its files in its private place.

download the files saved in the ios app

I am designing an ios app which collects the user data and saves the data into a .txt file. I am currently using the sandbox in organizer in xcode to download these files. However, I want the users who do not have xcode to access these files as well.
So are there any ways that I can download these files either via USB, or via FTP to a server, or via iCloud, or via Bluetooth, or via WIFI?
iTunes File Sharing would probably be the easiest method of getting files out of your app. You basically just add the UIFileSharingEnabled key to your app's Info.plist, then save the file to the sandbox's ~/Documents/ directory.
Here's a tutorial if you want a more in-depth discussion of how to use file sharing.
Probably most easiest way is to dump file content to UIPasteboard.

How to choose files from iPhone?

In my app I have to upload files to server.
For that I need to view and choose files from my iPhone and iPad. (any kind of files i.e pdf , doc,dock , mp3 etc etc).
How can I get the path for these files and how can I choose them in my application.
Generally in iPhone Where are these files are stored? how we can fetch them in our application?
Is there any thing like UIImagePickerController to pick file from iPhone?
There are classes that allow you to interact with various media types that may be on an iOS based device.
As you mention UIImagePickerController.
For music, you can use a similar class: MPMediaPickerControllerDelegate.
With regard to other arbitrary documents;
There is no device-wide document store, and you cannot access files stored inside another app's app bundle, thus you cannot access saved PDF/doc files. There is no shared place for the user to save such PDFs in the first place. Which is why media libraries have specific APIs to access them because they are device-wide libraries.
The most you can do is register your app as a viewer of PDF documents. This would allow other apps to open a PDF in your app if they use a UIDocumentInteractionController.
Your best option is probably to use File Sharing which will allow your application to own files on the device which can be synced via iTunes.
This will enable you to create your own UI, to present these files from your applications document folder.
Further reading: iOS File System Basics, File System Programming Guide.

Resources