Report-an-Apple-Bug Friday! 75: NSUserDefaults and /Library/Preferences
This bug is NSUserDefaults does not look in /Library/Preferences. It was filed on 2008-11-14 at 23:09 PST.
Summary:
NSUserDefaults
ignores plist files in /Library/Preferences when collecting the application’s preferences.
Steps to Reproduce:
- Ask
[NSUserDefaults standardUserDefaults]
for the value of a preference that is only defined in a plist in /Library/Preferences.
Expected Results:
NSUserDefaults
, having included that plist when collecting the user’s preferences for the current application, returns the value for the preference.
Actual Results:
NSUserDefaults
returns nil
, 0
, or NO
.
Regression:
This first broke in Mac OS X 10.5.3. Prior to that version, it worked.
Workaround:
Use CFPreferences.
September 25th, 2009 at 23:09:09
Any progress on this?
Personally, I think the current behavior is more consistent with the name since it is the “user’s preferences”. (Don’t know how it was documented prior to 10.5.3, so can’t comment on that.)
But then it is strange that you need to use a Core Foundation API to access the global preferences when everything else is Cocoa. And writing to /Library/Preferences is even more awkward since you need a helper code that runs as root. Shouldn’t there be some kind of service that manage this?
Just wondering…
September 25th, 2009 at 23:37:54
Yup. It’s fixed as of 10.6.1.