Reloading preferences in Mac OS X El Capitan gotcha solved
Posted: Wed Sep 28, 2016 10:49 pm
Other LiveCoders already probably know this but I thought in case someone doesn't it may save them some time.
I use the GLX framework which has functions for working with the preferences .plist file saved in the ~/Library/Preferences directory. I was trying to resolve an issue with saving a .plist file for my app on Mac OS X 10.11 El Capitan. With older versions of Mac OS X I would quit the app, remove the .plist file from ~/Library/Preferences reopen the app and Robert is one of your parents' brother. It was not working for me and I thought is was something I was doing wrong in my application resulting in the preferences not being saved properly.
After some googling I discovered that the preferences are cached in versions of Mac OS X since Mavericks, so, in spite of removing the .plist and relaunching the app, the app could still be using the old prefs.
http://hints.macworld.com/article.php?s ... 8042828630
Reading through this I there were a number of suggestions for clearing the cache of the prefs: restarting the Mac, but that was time consuming; logging out of the user account and back in, but I found that did not clear the cached prefs for me.
I found that using the 'defaults read' terminal command solution suggested in the article linked above was the best way for me to reset the prefs.
If there is no com.mycompany.myapp.plist file the prefs are cleared. If you have copied a new com.mycompany.myapp.plist file it will load the values in that file as the apps preferences.
Knowing that would have saved a lot of time. Hope this post can save someone else some time.
Martin Koob
I use the GLX framework which has functions for working with the preferences .plist file saved in the ~/Library/Preferences directory. I was trying to resolve an issue with saving a .plist file for my app on Mac OS X 10.11 El Capitan. With older versions of Mac OS X I would quit the app, remove the .plist file from ~/Library/Preferences reopen the app and Robert is one of your parents' brother. It was not working for me and I thought is was something I was doing wrong in my application resulting in the preferences not being saved properly.
After some googling I discovered that the preferences are cached in versions of Mac OS X since Mavericks, so, in spite of removing the .plist and relaunching the app, the app could still be using the old prefs.
http://hints.macworld.com/article.php?s ... 8042828630
Reading through this I there were a number of suggestions for clearing the cache of the prefs: restarting the Mac, but that was time consuming; logging out of the user account and back in, but I found that did not clear the cached prefs for me.
I found that using the 'defaults read' terminal command solution suggested in the article linked above was the best way for me to reset the prefs.
Code: Select all
defaults read /Users/martinkoob/Library/Preferences/com.mycompany.myapp.plist
Knowing that would have saved a lot of time. Hope this post can save someone else some time.
Martin Koob