简体   繁体   中英

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. 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. 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

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.

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. 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.

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). 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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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