2

I am working on an app which is extensively based on Core data. I got several entities and relationships. The format is kinda like this -

There is an entity "CARDS" which has one to many relationship with "RECIPIENTS" (another entity) and "CUSTOMERS" (another entity). The recipients and customers can be added/modified/deleted by the user. The list is stored in a table view.

I want to do an export of that data (recipient, customers etc.) via email. But all that is stored in Core data right? So Do I have to store that in documents directory somewhere or get the path to where it is stored in core data?

I followed these links but they don't use core data as such to store the data, will the logic be the same as shown in the link below: -

http://www.raywenderlich.com/1948/itunes-tutorial-for-ios-how-to-integrate-itunes-file-sharing-with-your-ios-app

http://www.raywenderlich.com/1980/email-tutorial-for-ios-how-to-import-and-export-app-data-via-email-in-your-ios-app

Any help will be really appreciated.

Thank you

6
  • Convert the DB to CSV (NSData) attach it to an email. Commented Aug 22, 2013 at 20:08
  • What is the purpose of the export (why CSV)? Commented Aug 22, 2013 at 20:15
  • @JustinMeiners How to do that? Commented Aug 22, 2013 at 20:26
  • @Wain Ok, not CSV, then like in the link they had exported in .sbz. I wanted to know how to accomplish this? Commented Aug 22, 2013 at 20:27
  • But why? Backup / sharing ? What is the recipient going to do with it? Can you just send the .sqlite file? Commented Aug 22, 2013 at 20:28

1 Answer 1

2

You specify the path to the .sqlite file when you create the store. You can copy that file (using NSFileManager) to another location and rename it (to change the extension to some custom value that is specific to your app). Once you have moved it, if you moved it to the correct folder it will automatically be available to iTunes sharing. Or, you can get the data for the file (using dataWithContentsOfFile:) and then add that as an attachment to an e-mail (again, specify a file extension for the attachment that is specific to your app).

You then want to look at teaching your app to handle that file extension to allow importing (see this).

Sign up to request clarification or add additional context in comments.

2 Comments

thanks for answering to that. I will follow what you said. So the links I mentioned are of No help here?
They are useful if they cover what you want to do. The first gives details of iTunes sharing and covers some things you want to do to import from there and where to put files so they can be exported that way. Basically all I'm saying is to copy the .sqlite file with a different name rather then bothering to export the file to some other format

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.