2012-11-28 109 views

回答

0

檢查是否有應用..

CFURLRef appURL = NULL; 
OSStatus result = LSFindApplicationForInfo (kLSUnknownCreator, 
              CFSTR("com.yourdomain.theapp"), //App bundle id. 
              NULL,      
              NULL,      
              &appURL); 
switch(result) 
{ 
    case noErr: 
     NSLog(@"Found my [email protected]: %@",appURL); 
     break; 
    case kLSApplicationNotFoundErr: 
     NSLog(@"App not found"); 
     break; 
    default: 
     NSLog(@"an error occurred: %d",result); 
     break;   
} 

if(appURL) 
    CFRelease(appURL); 
0

下面的代碼應該回到你的可執行文件的完整路徑:

[[[NSProcessInfo processInfo] arguments] objectAtIndex:0] 

然後檢查其是否屬於內部/應用

3

,你應該能夠使用下面的命令來獲取的路徑可執行

[[NSBundle mainBundle] executablePath] 
相關問題