如何将文件保存到iPhone? [英] How to save files onto an iPhone?

查看:183
本文介绍了如何将文件保存到iPhone?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,大多数人可能会发现有点奇怪。我正在为OS X做一个应用程序,但我需要它来写入文本文件到一个iPhone文件夹。我知道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.

我认为这将是简单到找到一个路径在iPhone连接时(如/ iPhone / Documents),但我不知道什么是路径。如果任何人可以告诉我如何找到路径,或者可以给我一些有用的信息的链接,我会非常非常好。

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

编辑:虽然这不是答案我想,我得到了我需要的。我认为所有这些答案给了我等量的信息,所以我很难选择接受哪个答案。我接受了一个,为我提供了另一种方式来获取文件到iPhone上。感谢所有的帮助,大家!

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!

推荐答案

您只能使用iTunes传输文件到您的应用程序。

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

为了使此工作正常工作,您的应用程序必须通过设置 UIFileSharingEnabled 键为 YES 。当这个操作完成后,您的应用程序将在安装和连接的设备显示在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.

这样,存储在应用程序文档文件夹中的任何文件都将可见到iTunes,并且在iTunes中复制到设备的任何文件将显示在文档文件夹中。您可以在应用程序中找到文档文件夹,如下所示:

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];

这篇关于如何将文件保存到iPhone?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆