How to determine if a user has an application in Cocoa

How can I determine if a user has an application, for example, echofon or twitter for mac, or if the user has pages or textmate? Any suggestions?

+5
source share
2 answers

Use NSWorkspace fullPathForApplication: to get the path to a set of applications. If this method returns nil, the application is not installed. For instance:

NSString *path = [[NSWorkspace sharedWorkspace] fullPathForApplication:@"Twitter"];

BOOL isTwitterInstalled = (nil != path);

URLForApplicationWithBundleIdentifier is another method you can use.

+8
source

I have never tried the code in the answer above, but the following works for me:

    if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"app-scheme://"]] ) {
        NSLog(@"This app is installed.");
    } else {
        NSLog(@"This app is not installed.");
    }

, . .

0

All Articles