开发者_JS百科Anyone can please provide sample code to launch a daemon from cocoa application using AuthorizationRef.
A daemon is generally defined as a long-running system service that has no user interaction. If that is what you mean by daemon then this is the wrong way to solve your problem most likely. Daemons should be started through launchctl and should have a preferences plist in /Library/LaunchDaemons or ~/Library/LaunchDaemons depending on whether they are system-wide or user-specific. Communication between your user application and the daemon can be done any way you please but I've found NotificationCenter (CFNotificationCenterRef) to be useful for such things.
However, if what you really need is to launch a tool to perform a specific task and that tool needs special privileges then check out the sample code here : http://developer.apple.com/library/mac/#documentation/Security/Conceptual/authorization_concepts/03authtasks/authtasks.html%23//apple_ref/doc/uid/TP30000995-CH206-TPXREF33
精彩评论