Saving Strategy
Saving Strategy
- Subject: Saving Strategy
- From: email@hidden (Demitri Muna)
- Date: Thu, 27 Nov 2003 13:17:11 -0500 (EST)
Hello,
I am wondering if anyone can give me some tips on a data saving strategy.
Let's say you've got an application like iTunes, and you need to manage the iTunes Library. This behaves as a database - the user never selects "Save Library". If I drag an MP3 into iTunes, it's added to the library. But I'm assuming that it doesn't write the "iTunes Music Library.xml" file each time that happens. For example, if you dragged 100 MP3s into the window, it would be rewriting the file 100 times successively, and that's hardly elegant.
One strategy I've come up with is to set up a repeating NSTimer and keep track of how many data items have changed. If when the timer fires something has changed, I do a save. Is this the best approach? If so, how often should that message fire? Finally, dragging a large number of items into iTunes can take a large (i.e. several multiples of the timer) amount of time. How can I avoid doing multiple saves (just an import flag, I suppose).
Another aspect I'm wondering about is the best way to save the data in a case like this. It seems to me that if I keep track of the actual items that have changed (which, like the iTunes Library are individually small, but there could be a large number of them), I can update those instead of rewriting the entire Library. Should I use something like keyed archiving, or just not worry and write it all at once each time?
One solution is to embed a database into my app, but that's overkill for what I need right now.
Thanks for any suggestions!
Demitri
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.