• 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: LSGetApplicationForItem -or- my crazy adventure with launch services
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LSGetApplicationForItem -or- my crazy adventure with launch services


  • Subject: Re: LSGetApplicationForItem -or- my crazy adventure with launch services
  • From: Douglas Davidson <email@hidden>
  • Date: Thu, 6 Sep 2001 09:00:51 -0700

On Wednesday, September 5, 2001, at 11:11 PM, email@hidden wrote:

[opensWithField setStringValue:(NSString *)LSGetApplicationForItem(&ref, kLSRolesAll, NULL, NULL)];

LSGetApplicationForItem doesn't return a string. It returns an OSStatus, i.e. a numeric error code. This is standard practice for Mac toolbox calls (as it is for many BSD calls). You should check this return value.

The real output from the function is returned by reference in the fourth argument (if you want a CFURLRef, which you probably do) or in the third argument (if you want an FSRef, which you probably don't). The CFURLRef that you get can be cast into an NSURL, then you can use the path method to get a string corresponding to its path. I believe you do get a reference to the CFURLRef.

There is also LSGetApplicationForURL, which will do the same thing without requiring conversion to an FSRef--it takes a CFURLRef or NSURL instead.

However, none of this is actually necessary, since -[NSWorkspace getInfoForFile:application:type:] will do the same thing for you, returning an autoreleased string by reference in the second argument.

Douglas Davidson


References: 
 >LSGetApplicationForItem -or- my crazy adventure with launch services (From: email@hidden)

  • Prev by Date: [Extreme Newbie] Cannot find class (factory) method
  • Next by Date: Re: [Extreme Newbie] Cannot find class (factory) method
  • Previous by thread: LSGetApplicationForItem -or- my crazy adventure with launch services
  • Next by thread: rotating windows 90 degreesin interface builder
  • Index(es):
    • Date
    • Thread