Re: Global (all-user) preferences for an application
Re: Global (all-user) preferences for an application
- Subject: Re: Global (all-user) preferences for an application
- From: Lee Ann Rucker <email@hidden>
- Date: Mon, 18 Mar 2013 15:30:40 -0700
On Mar 18, 2013, at 2:12 PM, Jean Suisse wrote:
>> Normally for shared preference or data you would write to a shared file in /Library/Application Support/companyname/filename, but you have to take special care if you're sandboxing your app.
>
> Indeed. It would seem this requires to be root.
You need permission to create the directory there, but then you can change the permissions on the directory so your app can write to it. You'll want a fallback if you can't get the initial permissions.
>
>> Never write into your application bundle. It will fail in many cases, most notably: read-only file systems and App Sandbox.
>
> So, what should I do?
>
>> You best bet is likely to turn to Core Foundation, which has built-in support for not only multi-user but also multi-computer: https://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFPreferences/CFPreferences.html#//apple_ref/doc/uid/10000129-SW1
>> You will likely need to programmatically synchronize the CF prefs with the user prefs if you want to use them with NSUserDefaults.
>
>
>> That is correct, and also you'll need to do this in a privileged helper tool. If you are fortunate enough to be requiring Mac OS X 10.7 or later, read Nathan de Vries' article on the topic…
>> http://atnan.com/blog/2012/02/29/modern-privileged-helper-tools-using-smjobbless-plus-xpc/
>
> Thanks for the links. "Luckly" enough, my app is 10.7+
> Isn't resorting to a SMJobBless helper tool endowed with XPC capabilities just for storing a few must-be-global preference a little overkill?
>
> Jean
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden