App defaults like userdefaults possible?

Hi there!

I've searching around, but wasn't able to find any documented way of doing the following....

In summary, it's possible to have a similar api to NSUserDefaults, but to store app common defaults shared by all users?

I know I can accomplish that by using custom plist, core data and so on, but I think it'd great to have a similar API like NSUserDefaults but to store common app defaults shared by all users...,

Thanks!!

Replies

NSUserDefaults is a layer on top of CFPreferences and you can access any-user preferences using kCFPreferencesAnyUser. The main drawback here is permissions:
  • A sandboxed will never be able to set an any-user preference.

  • Even a non-sandboxed app can have trouble setting any-user preferences. Last time I tried this only worked if the app was being run by an admin user but macOS is getting increasingly strict about this sort of thing.

Anyway, it’s something for you to play around with.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Great, thanks! will play with that for sure!