简体   繁体   English

创建数据的自定义格式文件,并以应用程序格式实现导出功能,并在应用程序中打开文件

[英]Create a custom format file of data and Implement export in app format feature and open in file in the application

I want to develop the feature in which the user can export the data in app format and can send the data file on email. 我想开发一个功能,用户可以在该功能中以app格式导出数据,并可以通过电子邮件发送数据文件。 Now the user delete the data from the application. 现在用户从应用程序中删除数据。 Then it goes to the mail and open the file. 然后它转到邮件并打开文件。 There come an option to open that file in the app, when it is pressed the deleted content is again shown in the application. 有一个选项可以在应用程序中打开该文件,当按下时,已删除的内容将再次显示在应用程序中。

I know little bit that I have to implement custom url but I am confused which database should I make, in sqlite or core data and how to export data in app format. 我知道我必须实现自定义URL,但我很困惑我应该在sqlite或核心数据中创建哪个数据库以及如何以app格式导出数据。 Also how to make custom format file. 另外如何制作自定义格式文件。

The concept is taken from minute taker app. 这个概念取自分钟应用程序。 https://itunes.apple.com/us/app/minutetaker-meeting-minutes/id519543986?mt=8 https://itunes.apple.com/us/app/minutetaker-meeting-minutes/id519543986?mt=8

Please see the attached some images for clear picture what I need to implement. 请查看附带的一些图片,以了解我需要实施的内容。

在此输入图像描述

Please help. 请帮忙。 Thanks in advance! 提前致谢!

First, research CFBundleDocumentTypes which is the mechanism for specifying what document types your app understands. 首先,研究CFBundleDocumentTypes ,它是指定应用理解的文档类型的机制。

Also, custom file types aren't anything special or mystical, they are simply an exported set of data (binary, XML, JSON, plain text, ...) which is in a format that your app understands. 此外,自定义文件类型不是任何特殊或神秘的,它们只是一组导出的数据(二进制,XML,JSON,纯文本......),其格式应该是您的应用理解的。 Usually your custom exported data files would have a special extension which allows the OS to know what to do with them. 通常,您的自定义导出数据文件将具有特殊扩展,允许操作系统知道如何处理它们。 You should probably also encode some header information so you can check that you understand the file contents (it really was created by your app and the version number matches for example). 您可能还应编码一些标题信息,以便检查您是否了解文件内容(它确实是由您的应用程序创建的,例如版本号匹配)。 You can create your export file as simply as building an NSDictionary of your data and writeToFile:atomically: but the exact method you use depends on what your data is and how you store it inside the app. 您可以像创建数据的NSDictionarywriteToFile:atomically一样创建导出文件但您使用的确切方法取决于您的数据以及如何将其存储在应用程序中。

If you're storing your data in CoreData inside the app then you could simply e-mail the on-disk data store file (consider copying and renaming it before sending it). 如果您将数据存储在应用程序内的Cor​​eData中,那么您只需通过电子邮件发送磁盘数据存储文件(考虑在发送之前复制并重命名)。 CoreData already holds version information and a system for dealing with version conflicts (upgrading from and old version and throwing exceptions when the versions are incompatible). CoreData已经拥有版本信息和用于处理版本冲突的系统(从旧版本升级并在版本不兼容时抛出异常)。

What you shouldn't do is decide how to store data inside the app based solely on your requirement to export and share the data. 您不应该做的是根据您导出和共享数据的要求决定如何在应用程序中存储数据。 These are 2 very different things. 这是两件非常不同的事情。 Choose your internal data storage based on what the app does at runtime and choose the exported data format based on what data actually needs to be saved in order to rebuild your data set. 根据应用程序在运行时的操作选择内部数据存储,并根据实际需要保存的数据选择导出的数据格式,以便重建数据集。 CoreData is great for your in-app storage, but an XML file is more likely to be a better solution for your exported data as it gives you a lot of control over what is exported and lots of options for adding additional meta data. CoreData非常适合您的应用内存储,但XML文件更有可能成为导出数据的更好解决方案,因为它可以让您对导出的内容和添加其他元数据的大量选项进行大量控制。

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

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