Re: How to store file metadata?
Re: How to store file metadata?
- Subject: Re: How to store file metadata?
- From: email@hidden
- Date: Sat, 23 Feb 2002 12:37:39 -0800
I am currently facing a design problem. My app is a viewer for PDF
files and i'd like to store some information like the displayed page,
magnification, mode, in order to retrieve them the next time a file is
read. How do I store this kind of information?
I'd recommend the resource fork of the file. Use Carbon's Resource
Manager to access it.
Hmm. I would not recommend this. A viewer application should not
modify the files viewed; it's intrusive, unexpected and dangerous. It
also has issues with locked files, files on file servers, files which
the user doesn't have permission to write to, etc. And finally, it has
issues with multiple users all using this viewer app on the same file
and overwriting each others viewing preferences, unless the resource
scheme somehow encoded each user's identity along with that user's
preferences.
There is a much simpler, more robust, and more standard way to do
this. Use Cocoa's user defaults mechanism. Write out the user's
viewing preferences to your application's user defaults, probably as a
dictionary. The defaults key that you use for this information would be
the file name, or some other file-specific identifier (perhaps someone
can recommend a better one than filename), which lets you look up the
user's viewing preferences for the file later.
Read the doc for NSUserDefaults for more information. It's quite easy
to use, especially since for this particular use you won't need to worry
about the concept of domains at all...
Ben Haller
Stick Software
_______________________________________________
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.