tags:

views:

169

answers:

3

Hi, I am developing an application in cocoa.I need to check whether iTunes is installed or not in the machine.Is there any way to find the installed applications????

A: 

iTunes is always installed, it's shipped with a clean install of OS X.

Tom
sometimes people delete stuff.
Graham Lee
What if the software is used in a managed lab environment where the sysadmins have removed iTunes as it's not being used for academic reasons?
Jeff Kelley
+7  A: 

The function LSFindApplicationForInfo() can take a bundle ID (e.g. com.apple.iTunes), so you can find out whether iTunes is installed by trying to look it up.

http://developer.apple.com/DOCUMENTATION/Carbon/Reference/LaunchServicesReference/Reference/reference.html

To answer the second part of your question, there is a hidden interface on LaunchServices to get a list of all application names. However, as your goal is to find whether iTunes is installed, don't use it - just look for iTunes.

Graham Lee
Or one could even use -[NSWorkspace absolutePathForAppBundleWithIdentifier:] (which probably calls down to LSFindApplicationForInfo() anyway)
Mike Abdullah
+1  A: 

As was mentioned by Mike Abdullah the correct cocoa call is:

NSString* iTunesPath = [ [ NSWorkspace sharedWorkspace ] 
     absolutePathForAppBundleWithIdentifier: @"com.apple.iTunes" ];
if( iTunesPath ) {
    // iTunes installed, do something
}
Jon Steinmetz