Strategy to keep track of stored files in the documents directory?
In my app, the user can save his input to disk. This is done with NSKeyedArchiver. Currently I simply name my files with a timestamp. But of course, the user may want to load one of them back in to keep on editing them.
What would be the most reliable / safe strategy to keep track of those files? I need to present the user a list of those files, so that he can choos开发者_C百科e one to open.
Currently I think of making an archived NSMutableArray which simply stores the file names, but I feel that this strategy is not really good. We all know when we save files sometimes something goes wrong, and this seems very likely to get currupted easily, or not? How would you do it?
If you've got all your files in one directory, and nothing else there, I would use -[NSFileManager contentsOfDirectoryAtPath:error:] to fetch an array of filenames in there. That's a little more robust than tracking these manually.
精彩评论