Re: Per-document preferences?
Re: Per-document preferences?
- Subject: Re: Per-document preferences?
- From: SA Dev <email@hidden>
- Date: Fri, 24 Jun 2005 20:33:56 -0400
On Jun 24, 2005, at 7:16 PM, James Bucanek wrote:
As I look at the problem, I think this is exactly what I'll do:
Create an NSMutableDictionary and store all of the user settings
and layout parameters. Using NSPropertyListSerialization, I
shouldn't have any trouble turning a dictionary of document
properties and user settings into an XML or binary file that I can
store inside the package.
Okay, here's where you're missing the magic that is Cocoa. Check
out NSDictionary's writeToFile:atomically: and its
initWithContentsOfFile: methods. It saves the data in plist (XML)
format.
What I'm dreading is having to save and restore the dozens of
little layout variables for the window. It looked like the
"autosave" feature of NSTableView, et. al. was designed to remove
this burden from the programmer, but it seems hopelessly tied to
the application defaults.
NSStringFromRect() and NSRectFromString() functions will make a
string that can be stored in your dictionary and turn that string
back into a rect (frame) for your window. For the rest, as long as
you can create (and restore from) a type that can be stored in a
dictionary (string, number, data), you're golden.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden