Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save files onto an iPhone?

I have a question that most of you might find a little odd. I am making an application for OS X, but I need it to write text files into an iPhone folder. I know the iPhone will have to be connected to the computer, and I do not think that emailing will work.

I thought it would be as simple as finding a path to the iPhone while it was connected (such as /iPhone/Documents), but I cannot figure out what the path is. If anybody can tell me how to find the path, or can give me a link to some useful information, I will be very greatful

EDIT: although it was not the answer I wanted, I got what I needed. I think all of these answers gave me an equal amount of information, so I had a hard time choosing which answer to accept. I accepted the one that provided me with an alternative way to get the files onto the iPhone. Thanks for all of the help, everyone!

like image 983
Justin Avatar asked May 13 '11 16:05

Justin


People also ask

How do I put files on my iPhone?

Drag and drop files from a folder or window onto the Documents list to copy them to your device. You can also click Add in the Documents list in iTunes, find the file or files you want to copy from your computer, and then click Add. iTunes copies these files to the app on your device.

When you save a file on iPhone Where does it go?

Generally, most people save files to the “Downloads” folder, so tap it. You'll see a list of all the files you've downloaded.

How do I save directly to my iPhone?

Tap Share, then scroll down and select Save to Files. Now choose a folder under On my iPhone and then tap Save in the top right. To move a document from your iCloud to your iPhone, open up the files app and deep (or long) press the file that you want to move until some options come up.


1 Answers

You will only be able to transfer files to and from your application using iTunes.

In order to get this to work your app must register for sharing documents in the Info.plist file by setting the UIFileSharingEnabled key to YES. When this is done your app will when installed and the device in connected show up on the "Application" tab in iTunes at the bottom. Highlight the app in the list to the left, and drag and drop files to the list on the right.

This way any file stored in the applications documents folder will be visible to iTunes, and any file copied to the device in iTunes will show up in the documents folder. You find the documents folder in your app like this:

NSArray* paths = NSSearchPathForDirectoriesInDomains(
                     NSDocumentDirectory, NSUserDomainMask, YES);
NSString* path = [paths lastObject];
like image 85
PeyloW Avatar answered Nov 14 '22 23:11

PeyloW