Add a file into the ios app - ios

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

Related

how to choose any document file from device in objective-c in ios

how to access any document files from device to our application for uploading to server and downloading from server ,save in device not in App can any one help me how to do this?
i searched from many days, but i didn't get any solution to how to get files from the device.
UIDocumentInteractionController *pdfPicker = [[UIDocumentInteractionController alloc] init];
pdfPicker.delegate = self; // ensure you set the delegate so when a PDF is chosen the right method can be called
[self presentViewController:pdfPicker animated:YES completion:nil];
i also implemented this code but its crashing the app. please help me, thanks in Advance.
Not Possible, You can not get list of documents available in other app from your app. however, if you want to bring files from other other app to your app you can implement following:
1) Register your app for supporting file type by defining required values in plist. in this way, when user will see file in mail, safari or some other app, they will see your app in open with option.
how to register the app to open the pdf file in my app in ipad
2) Create share extension: whenever user will share file which you are supporting, they will see your app in option.
Code to share file path/file between a share extension and iOS app
from both option above, you will get selected document path into your app. you can upload that doc to server if required.
It is not possible to access all files in an iOS device outside the sandbox of the app. What you can do is:
Access all the files in Gallery using UIImagePickerController.
Access all the user files in network- Dropbox/Google drive/iCloud. They all have separate public APIs that can be downloaded and used to download/upload files in network.
In this way, you can access most of the user files and use the same in your application.

Share document in iOS app

I have a requirement to sharing files (PDF,PPT,Word etc.) from my App, I know we can get them from Drop Box, Google Drive, Box, iCloud etc..
Is there any SDK provided by iOS which we can handle locally with out downloading other Framework. For example the new WhatsApp feature having the share document.
The UI and all seems to be from Native SDK, how can we access it ?
If you want to pickup documents to your application, you can see UIDocumentPickerViewController and UIDocumentMenuViewController
Take a look at :
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDocumentPickerViewController_Class/
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDocumentMenuViewController_Class/
You have to make a Share extension, then if the user has those apps, the extension will be able to easily share your contents.
Take a look at :
https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Share.html#//apple_ref/doc/uid/TP40014214-CH12-SW1
If your documents are from a known source and have to be downloaded and uploaded, you also can do a Document provider extension.
Take a look at :
https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/FileProvider.html#//apple_ref/doc/uid/TP40014214-CH18-SW1

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.

Accessing Files from iOS

I know it is possible to access the gallery photos and pick them as UIImage using UIImagePickerController, but I want to know whether all other files like doc, txt, pdf etc can be accessed from device please help.
thanks
You can, but there's no built-in picker like there is for images. Take a look at the NSFileManager class for enumerating directories and working with files.
There is no GUI API to access the file system, you can create your own UI and read and write from your app's documents folder though.
There is no universal space to store that document in iphone like photos and videos. but you can store in your app and and using itunes file sharing you can access it.
here is the way to enable itunes file sharing.
you can store in icloud and access it from app.
Select your project in top left
Select target in next column
Click on Info tab
In Custom iOS Target Properties, hover mouse over any row and click +
In popup, select "Application supports iTunes file sharing", then set Value to YES on right
Click Validate Settings at bottom to make sure all is good

Storing & Reading documents present in iCloud

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 ?

Resources