Vasa
Vasa

Reputation: 135

Making my own container file type

I would like to create a file type with a personal extension by combining two other file types, like .mp3 and .pdf.

Later I need to re-open the custom files I've made and be able to use the included files in my app.

How do I do that on iOS?

Upvotes: 2

Views: 268

Answers (1)

rmaddy
rmaddy

Reputation: 318774

One option is to append the data of the two files together. Include a few bytes of data at the start that tell you the size of each and maybe their original filenames. Then when you want to recreate the two files from the one custom one, you read your header to get the sizes and names, then use that info to recreate the original files.

Another option would be to zip the two files together. Just give the zip file your own custom extension.

Another option would be to use an NSFileWrapper. Include the two regular files in the wrapper.

Upvotes: 2

Related Questions