简体   繁体   English

iOS从文档目录加载文件

[英]iOS load file from documents directory

I'm creating a registration app. 我正在创建一个注册应用程序。 It has two tabs, one tab is the registration form for students to fill out, and the other gives the user the ability to update the form. 它有两个选项卡,一个选项卡是学生填写的注册表格,另一个选项卡使用户可以更新表格。

I'm still pretty new to iOS development, as well as Objective-c. 我仍然对iOS开发以及Objective-c相当陌生。 Currently I'm saving a .csv file that contains the form data in the documents directory, in hopes that the app user can pull that file off the iPad and open it in microsoft excel. 当前,我正在文档目录中保存一个包含表单数据的.csv文件,希望应用程序用户可以将该文件从iPad中拉出并在microsoft excel中打开。 Unfortunately I'm not an Apple Developer yet, so I am not able to test it with a physical device, and I have read the documentation but didn't find what I was looking for. 不幸的是,我还不是Apple Developer,所以我无法在物理设备上对其进行测试,并且我已经阅读了文档,但没有找到我想要的东西。

Is this possible? 这可能吗? If not, what is the best way to save a file and then have the ability to upload it to a computer? 如果不是,保存文件然后将其上传到计算机的最佳方法是什么?

There is more than one way to provide your users with a way to receive files that are saved in your app (some options already mentioned in the comments). 有多种方法可以为您的用户提供一种接收保存在您的应用程序中的文件的方式(注释中已经提到了某些选项)。

You can implement several methods and let your users choose their preferred one, taking into account that not all of them would like to use the same method (using iTunes for file sharing is not for everyone for example). 考虑到并非所有人都希望使用相同的方法,您可以实现多种方法并让您的用户选择他们喜欢的方法(例如,并非所有人都使用iTunes进行文件共享)。

So here are the options you have, there are probably more but I think this would be enough for this purpose: 因此,这里有您可以选择的选项,可能还有更多,但我认为这足以满足此目的:

  1. Email the file as an attachment 通过电子邮件将文件作为附件发送
  2. Upload the file to a 3rd party service: Dropbox, Google Drive, iCloud, Evernote, etc. 将文件上传到第三方服务:Dropbox,Google云端硬盘,iCloud,Evernote等。
  3. Upload to FTP. 上载到FTP。
  4. iTunes file sharing. iTunes文件共享。 You can allow users to access files in the documents folder via iTunes. 您可以允许用户通过iTunes访问document文件夹中的文件。 Look for info about the UIFileSharingEnabled key. 查找有关UIFileSharingEnabled键的信息。

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

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