简体   繁体   English

从用户文档目录中检索文件

[英]Retrieve File from User's Documents Directory

I can successfully read and write a text file within the user's Documents directory for my iOS app. 我可以为我的iOS应用成功在用户的Documents目录中读写文本文件。 However, I will need to view this text file myself , retrieving it from the user's iPad. 然而,我将需要查看这个文本文件我自己 ,从用户的iPad上获取它。

I looked into sending it via email, but all of the links pointed me to MFMailComposer rather than some automated way of sending email. 我考虑通过电子邮件发送,但是所有链接都将我指向MFMailComposer,而不是某种自动发送电子邮件的方式。 I looked into FTP uploading, but Apple doesn't seem to want me to use password protected FTP in my app. 我研究了FTP上传,但是Apple似乎不希望我在应用中使用受密码保护的FTP。 How can I go about making a text file in the user's Documents directory accessible from my own computer? 如何通过我自己的计算机访问用户文档目录中的文本文件? I feel as if there must be some easier options for this task. 我觉得似乎必须为该任务提供一些更简单的选择。

Well, there's iTunes File Sharing. 好吧,这里有iTunes文件共享。 It is probably the most "direct" way to do it, as it doesn't require any 3rd party service and frameworks. 这可能是最“直接”的方法,因为它不需要任何第三方服务和框架。 Read more about it at Ray Wenderlich's - the tutorial is a bit dated, but should still be valid for the most part. Ray Wenderlich处了解有关此内容的更多信息-该教程有些陈旧,但在大多数情况下仍应是有效的。

For over the air sharing, I'd recommend dropbox . 对于无线共享,我建议使用dropbox It is easy to use within your app and many of your future users will have an account already. 在您的应用程序中易于使用,并且您的许多未来用户已经拥有一个帐户。

Lastly, if you require the functionality for your development purposes, you might want to take a look at iExplorer (formerly iPhone Explorer). 最后,如果您出于开发目的需要功能,则可能需要看一下iExplorer (以前的iPhone Explorer)。 It will allow you direct access to your apps documents folder and doesn't require you to alter your app in any way to work. 它将允许您直接访问您的应用程序文档文件夹,而不需要您以任何方式更改应用程序。

  1. Go to your App-Info.plist and add a row under Information Property List. 转到您的App-Info.plist,然后在“信息属性列表”下添加一行。

  2. Name that row Application supports iTunes file sharing. 将该行命名为Application支持iTunes文件共享。 You should see it auto completing. 您应该看到它自动完成。

  3. Set the value to YES 将值设置为是

That's all you need to do. 这就是您需要做的。 Now you can access the files from your iTunes. 现在,您可以从iTunes访问文件。

As of August 4, 2014, open up iTunes. 从2014年8月4日起,打开iTunes。 In the top right corner, click on your device, but NOT the eject button. 在右上角,单击设备,但不单击弹出按钮。 It might say iPhone. 可能会说iPhone。 Click on the Apps tab and scroll to the bottom to File Sharing. 单击“应用程序”选项卡,然后滚动到底部的“文件共享”。 Click on the desired app and the documents will appear. 单击所需的应用程序,然后将显示文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM