how many instances of "e" are there in:
q: mac os x preferences saving, when to apply/save changes made by user it is typical for mac os x apps to have preferences that apply seamlessly, and preferences dialogs don't have "ok" or "apply" button. i want to implement this behavior in my project, but i can't decide when to apply/save changes made by user. 
it's quite clear that checkboxes and drop-downs can be saved immediately upon change, but when it comes to text fields, this approach seems questionable. for example, entering "programming.stackexchange.com" as host address will trigger 29 hdd writes, which seems just wrong. moreover, in my simple implementation this will cause the entire settings file to be rewritten.
so is there any standard way to implement macos-like preferences?

a: one reasonable way to accomplish this is as follows:


*

*for an input type that has a discrete selection such as a check box, radio button, or list: save the setting as soon as the user makes the selection.

*for an input type that has freeform selection such as a text box: save the setting as soon as the input element loses focus or the dialog is dismissed. for longer text boxes (e.g. a rich text element that might contain complex data and a lot of it) it might make sense to save data every few seconds in addition to the previous criteria. in fact this is the same method used when writing questions and answers here on stack exchange.


it is important to be mindful that in addition to saving to persistent storage (i.e. hard disk) updating preferences may also trigger events in your application that update the ui elsewhere in the program. handling these events may also consume resources such as cpu and memory. while not strictly addressing your question, it is closely related and worth thinking about while you implement a solution such as this.

a: if you're using nsdefaults (or cfpreferences), you can update the default settings immediately. they get pushed to the background process cfprefsd (short for core foundation preferences daemon) which holds them in ram and writes to disk at its leisure. killing your app does not kill cfprefsd, so the settings don't get lost. 
(killing cfprefsd, which i've actually seen people suggest as a way to keep it from overwriting a .plist that they've just modified behind its back, can wreak unbounded collateral damage. that would be a no-no.)

user
The passage contains two hundred and thirty-six "e"s.
assistant