I have a preferences pane that uses the Shared User Defaults Controller, which reading and saving preferences a piece of cake. It seems though that when changes are made to the fields, they aren’t immediately saved to the plist fie. This creates a problem when my application needs to re-read the file immediately after the change has been made and the plist still hasn’t been updated.
How can I force the preferences pane to update the preferences file immediately?
This will automatically save any change you do right away to disk:
If you need this only in specific cases, you can also use and save some of the expensive I/O (you really should try to let the cache mechanism cache as much as possible instead of writing everything right away to disk):
Also, are you sure that you are trying to solve the right problem? You can always get the up to date version of the user defaults by querying
NSUserDefaultswhere you don’t need to care about wether the current version is cached in RAM or already written to disk.