Debe utilizar Launch Services hacer esto, específicamente la función LSFindApplicationForInfo()
.
que lo utilice de esta manera:
#import <ApplicationServices/ApplicationServices.h>
CFURLRef appURL = NULL;
OSStatus result = LSFindApplicationForInfo (
kLSUnknownCreator, //creator codes are dead, so we don't care about it
CFSTR("com.apple.Safari"), //you can use the bundle ID here
NULL, //or the name of the app here (CFSTR("Safari.app"))
NULL, //this is used if you want an FSRef rather than a CFURLRef
&appURL
);
switch(result)
{
case noErr:
NSLog(@"the app's URL is: %@",appURL);
break;
case kLSApplicationNotFoundErr:
NSLog(@"app not found");
break;
default:
NSLog(@"an error occurred: %d",result);
break;
}
//the CFURLRef returned from the function is retained as per the docs so we must release it
if(appURL)
CFRelease(appURL);
no olvide si (appURL) antes del lanzamiento, en caso de que no se encuentre, intentará liberar un objeto inexistente, generando un bloqueo – Daniel
Buen punto, reparado. –
Nota: LSFindApplicationForInfo parece obsoleto a partir de 10.12. Alguien sabe una alternativa? – Tony