• 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: Autostart item in user profile.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Autostart item in user profile.


  • Subject: Re: Autostart item in user profile.
  • From: Jerry Krinock <email@hidden>
  • Date: Sat, 27 Sep 2008 07:41:22 -0700

Two solutions have been suggested, launchd and "Login Item". (Indeed, LoginItemsAE is unreliable and depracated.) I've never seen an explanation of which one to use. Here are my conclusions:

• If you do not want the user to be able to see and control your item in System Preferences, or if you have more complicated instructions than simply "always launch at login", use launchd. This is probably appropriate for background agents/daemons/whatever.

• If you want the user to be able to see and control en/disable your item in System Preferences, make it a Login Item. This is probably more appropriate for apps. You can set/unset Login Items programmatically using the new LSSharedFileList API...

On 2008 Sep, 25, at 20:25, Ken Thomases wrote:

Actually, Leopard introduced the LSSharedFileList API, which is the new preferred solution. Unfortunately, this API is undocumented. The only documentation (other than a brief mention in the release notes) is the header file:

/System/Library/Frameworks/CoreServices.framework/Frameworks/ LaunchServices.framework/Headers/LSSharedFileList.h


Yes, this is more reliable than LoginItemsAE and should be used in any project that requires 10.5. But, yes it's undocumented, not very nice to use (Carbon-style C API) and also there is a bug.

To make it nicer to use, I wrote a Cocoa wrapper a few months ago, but forgot to make it available. I had been waiting for Apple to fix a bug, but apparently my bug report didn't ring the bell on the priority list. Oh, well. Here is the project...

http://sheepsystems.com/files/SSYLoginItems.zip

Click in the Documentation subfolder on index.html to see HeaderDoc documentation.

Jerry


Here's the text of the bug:

Apple Bug Reporter.  Problem ID 5901742

30-Apr-2008 01:48 PM Jerry Krinock:

* SUMMARY The 'hidden' attribute for Login Items in the LSSharedList API has a disconnect with the reality. In more detail, when reading a Login Item, the 'hidden' attribute is read as 0, even if it is in fact '1', unless the 'hidden' attribute has been set by the LSSharedList API. In that case, it doesn't really set, but when you read it back with the API, it says that it is set, even though in fact it is not.

* STEPS TO REPRODUCE Build and run the attached project. Follow the prompts shown in the the console.

* EXPECTED RESULTS In all tests, the values read and written using the LSSharedList API and shown in the log should agree with what is shown in the System Preferences application.

* ACTUAL RESULTS In Test #1, items which have the "Hide" box checked in System Preferences read from the API hidden=0. In Test #5, although the API set Safari to "Hide" and the API read it back as hidden=1, if you look in System Preferences you see that the "Hide" box is not checked.
_______________________________________________


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


References: 
 >Re: Autostart item in user profile. (From: Gregory Weston <email@hidden>)
 >Re: Autostart item in user profile. (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Use other key than "tab" to cycle through text fields
  • Next by Date: design pattern for data acquisition in background thread?
  • Previous by thread: Re: Autostart item in user profile.
  • Next by thread: Re: What happens to the user dictionary when coalescing notifications in NSNotificationQueue?
  • Index(es):
    • Date
    • Thread