I am writing an NSDocument based application that has an SQLite database that I wish to tag along in the document bundle. It consists of some number of tables, with the schema for each table being a timestamp and a value. This database will start out small, but could grow to a sizable amount over time. The application is updating the database "behind NSDocument's back."
What I have attempted to do thus far is override the writeToURL:ofType:error:
method, which can get passed some convoluted URL like:
file://localhost/private/var/folders/mr/l1z6gdls0fb3t28m3z1bz6lw0000gn/T/TemporaryItems/(A%20Document%20Being%20Saved%20By%MyApp%2031)/Untitled.wsdoc
At this point I am forced, if you will, to use an in-memory database, then suck up the entire contents of that database into an NSFileWrapper. It works, but it doesn't scale well. Doing his each time someone presses Command-S (or worse yet, I turn on autosaving) could be a very expensive operation if the database is huge, say 200-300MB or more (which is not out of the realm of possibility for this application).
So I'm wondering: is it possible to manage an SQLite file outside of the purview of NSDocument while still having it reside IN the document bundle so that the database can exist within the bundle as it is moved/copied?