Re: Preferences caching?
Re: Preferences caching?
- Subject: Re: Preferences caching?
- From: Uli Kusterer <email@hidden>
- Date: Wed, 11 Dec 2013 10:04:22 +0100
On 10 Dec 2013, at 18:08, Kyle Sluder <email@hidden> wrote:
>> On Dec 10, 2013, at 7:46 AM, Jakob Egger <email@hidden> wrote:
>> Or does OS X Mavericks recreate deleted preference files in some cases?
>
> Bingo. You are now caught up with the original post in this thread.
> The plist files are and always have been an implementation detail. The only supported interface to preferences has always been through CFPreferences/NSUserDefaults, whether via code or the defaults command line tool.
To add a little bit of detail, the preferences are handled by a daemon, which seems to read in the prefs file at startup, and then only looks at its cached copy in RAM until it gets terminated, at which point they get written back to the file. Every app that wants to read preferences (indirectly, via CFPrefs or NSUD, including the ‘defaults’ command line tool) calls this daemon to get the values in RAM.
Once that daemon has loaded the preferences into RAM, you can do whatever you want to a prefs file, it gets ignored. Also, reading that prefs file directly instead of through API that talks to the daemon may give outdated results. When you delete the prefs file, it’s usually *before* the system has shut down the CFPrefs daemon, so what will happen after the deletion is that the daemon will write its changed settings back out, re-creating the plist file.
Graham Cox wrote:
> Great. For me. For users in the field, the command line is the badlands, and we can’t expect many users to be comfortable doing that. Trashing a file is at least something they can understand, even if sometimes even that can be an ordeal getting them to the ~/Library/Preferences folder, now it’s hidden by default.
>
> Really, Apple are supposed to be the champions of the average user aren’t they? Have they talked to any recently? Honestly, it would serve everyone well if every developer served a month in a call centre.
>
> I guess we’re going to have to put a button somewhere that’s going to do this for them. Sigh.
As others have said, deleting prefs shouldn’t be so common that you need to have a button in your UI for it. If it is, your app has some sort of problem. That said, we actually created a ‘supporter’ application to help our customers do things like that, including save and send off all settings files to our support, reset the application to a pristine installation, restore saved settings files, save system profile information etc. (given we include hardware, some of which does network communications, and are the market leader in our segment, it was worth the effort to spend time on a ‘push one button’ solution for this edge case).
In your case, I could see you sending them a shell script with a .command extension that does a defaults delete call to nuke your prefs domain. They can simply double-click that, and you can have it do a ‘clear’ and then display a friendly message like “GrahamApp Preferences reset to factory defaults”.
Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden