1

I'm using user defaults to store my app data.

I have some global data that is relevant for all users on the same machine.

How can I share this data between them?

NSUserDefaults' initWithSuiteName did not work.

The only workaround I found it to write to a hidden file in the root folder, but that is too visible to the users.

Mugen
  • 8,301
  • 10
  • 62
  • 140

3 Answers3

1

The closest you could do is to make all of the users be members of a single group, then make a group writable file with the shared data. It could be a plist and it could even be accessed via the defaults API, assuming you don't need multiple simultaneous write access.

bbum
  • 162,346
  • 23
  • 271
  • 359
1

You could use CFPreferences APIs instead of NSUserDefaults, passing kCFPreferencesAnyUser as the user name parameter. However, setting defaults for all users requires admin privileges.

JWWalker
  • 22,385
  • 6
  • 55
  • 76
1

You can use the /Users/Shared directory like iTunes & the App Store.