Re: NSUserDefaultsController problems
Re: NSUserDefaultsController problems
- Subject: Re: NSUserDefaultsController problems
- From: Matt Neuburg <email@hidden>
- Date: Fri, 30 Jul 2004 15:08:30 -0700
On Fri, 30 Jul 2004 16:09:50 -0400, Doug Steigerwald <email@hidden>
said:
>
I've been working on a part of an app that I'm writing to revert all
>
the bindings values in the app to initialValues when I hit cancel on a
>
custom sheet. The changed values go back to their initial values, but
>
when I quit the application, the plist is deleted.
>
- (IBAction)cancelSheet:(id)sender
>
{
>
[[NSUserDefaultsController sharedUserDefaultsController]
>
revertToInitialValues:sender];
>
[NSApp endSheet:pSheet];
>
}
You should not have a Cancel button call revertToInitialValues:! You should
have a button saying something like Reset All To Factory Defaults if that's
what you to do.
If the user cancels, s/he simply expects changes in the prefs dialog not to
take. So if everything in the prefs dialog is bound, just call revert:.
The initialValues are factory defaults that can be reverted to, and they
exist for no other purpose than for them to be applied with
revertToInitialValues. Seen in this light, deleting the plist makes perfect
sense. You are asking to revert to factory defaults. That means the state of
things before there was a plist - the state of things the day the user
downloaded the app and started it up for the very first time. So
revertToInitialValues must delete the plist; otherwise, other stuff that may
have been written into it will still be there, and we will not be back at a
clean fresh-from-the-factory state.
By the same token, merely saying registerDefaults: does not create a plist
file - there is no need.
m.
--
matt neuburg, phd = email@hidden, <
http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
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.