• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Launch Daemon Best Practices?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Launch Daemon Best Practices?


  • Subject: Re: Launch Daemon Best Practices?
  • From: Karl Moskowski <email@hidden>
  • Date: Tue, 11 Mar 2008 21:39:46 -0400


On 11-Mar-08, at 8:18 PM, Chris Suter wrote:


On 12/03/2008, at 10:16 AM, Karl Moskowski wrote:

Why not do it the other way round? Update settings via distributed
objects, and have the daemon write them to /Library/Preferences.

Good idea. Thanks, Hamish.

I'm not so sure it's a good idea. The problem is that it relies on your daemon running which whilst might be true most of the time, it might not be—if it's restarting for example. I personally would write the defaults from the GUI application.


Do processes run by launchd automatically write their preference plists to /Library/Preferences/ using NSUserDefaults?

No I don't think they will. If you're running as root, preferences will get written to /var/root/Library/Preferences which is not what you want.

Why would that location be wrong?

To write to /Library/Preferences I think you'll need to use CFPreferencesSetValue.

If you can get away with it you could just periodically check to see if the defaults have changed. A Cocoa application will periodically synchronise the defaults but you'll still have to check to see if anything has changed. If that doesn't work for you, you can use distributed objects as you've suggested or you can use any of the other IPC mechanisms available to you.


After Hamish's original response, I thought the way to go would be to create a proxy object that behaves like NSUserDefaults (KVC- and KVO- compliant, so it can be wired up in IB) but really just interacts with a corresponding object in the daemon from DO. That way, the daemon's settings are fresh, and the UI always reflects the correct state.

(Anyway, I did find some Panther-era posts to cocoa-dev asking about writing to /Library/Preferences/. The response then was that CFPreferencesSetValue was the way to go, and requests for enhancement to NSUserDefaults had been filed. I was hoping they had been met and I was just missing something.)

BTW, which Xcode project template would be most appropriate for this type of launch daemon? CoreFoundation Tool or CoreServices Tool?

--Karl.

_______________________________________________

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


  • Follow-Ups:
    • Re: Launch Daemon Best Practices?
      • From: Chris Suter <email@hidden>
References: 
 >Launch Daemon Best Practices? (From: Karl Moskowski <email@hidden>)
 >Re: Launch Daemon Best Practices? (From: "Hamish Allan" <email@hidden>)
 >Re: Launch Daemon Best Practices? (From: Karl Moskowski <email@hidden>)
 >Re: Launch Daemon Best Practices? (From: Chris Suter <email@hidden>)

  • Prev by Date: Re: warning: assignment from distinct Objective-C type
  • Next by Date: Re: Launch Daemon Best Practices?
  • Previous by thread: Re: Launch Daemon Best Practices?
  • Next by thread: Re: Launch Daemon Best Practices?
  • Index(es):
    • Date
    • Thread