I have a class that I'd like to be able to open, and export to a file. It doesn't need to be edited - this is simply a way to share part objects CoreData database with other users of my app, so I don't think I need the complexity of subclassing NSDocument
.
The class is pretty basic, with two properties String
and a filename for a NSImage
that references an image in the app sandbox.
Initially, I thought of using a Document Bundle, basically a folder with the images (if required) and a plist with the strings and image file names.
Now, I'm leaning toward creating a class-just-for-export-and-import that uses NSCoding
to save the images and the strings into a file.
Here's what I'm not sure about:
- is this a good idea? Am I missing something here?
- can I save an array of objects with
NSImage
andString
properties into a single file? I know I can save an image, fairly easily, but can I bundle them up into a single document? IsNSCoding
the way to do this? - Do I need to convert the
NSImage
toNSData
first? - How does my decoder know which part of the file is a
String
and which part is aNSImage
?
I have done my research! There's lots of info about saving an image, or saving a NSDocument
, but I just want a simple way for users to export and import arbitrary data into, and out of, my application's core data store.