Hi,
I am writing a document based application on OS X. One feature oft this application will be an "import" function.
This function will read data files from the disk which contain data as raw BLOBs and can be parsed into one oder more documents. For this function I will have to create documents programatically. The main problem is, that NSDocumentController
only has the makeDocumentWithContentsOfURL:ofType:error:
method for creating a document from existing data. There are several way to create my documents and I'd like to know which one would be the cleanest way.
- I could write the data for the documents into separate files on the disk and call
makeDocumentWithContentsOfURL:ofType:error
: for each of them. This seems rather inelegant and could slow the app down with large amounts of data. - I could create empty documents with the
NSDocumentController
and fill the data in. - I could create the documents in the import function and add them to the
NSDocumentController
with theaddDocument:
method. I don't know if this will work because this method seems to be a hook for subclassing. - I could subclass
NSDocumentController
an add amakeDocumentFromData:ofType:error:
method. I think this would be clean but more complicated.
What do you think?
Best Regards, Chris