views:

27

answers:

1

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 choose 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?

+2  A: 

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.

Ben Gottlieb
but I can't make an directory inside the documents directory, or can I?
dontWatchMyProfile
Sure you can, check the documentation on NSFileManager.
Ben Gottlieb