Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何检查Mac计算机上是否安装了应用程序的多个版本_Macos_Cocoa - Fatal编程技术网

Macos 如何检查Mac计算机上是否安装了应用程序的多个版本

Macos 如何检查Mac计算机上是否安装了应用程序的多个版本,macos,cocoa,Macos,Cocoa,我需要检查Mac电脑上是否安装了应用程序的多个版本 我需要检查mac电脑上是否安装了多个版本的Google Chrome 使用最新版本的Google Chrome打开一个URL。NSURL*URL=[[NSURL alloc]initWithScheme:@“http”host:@“example.host.com”path:@”/example“; NSURL *url = [[NSURL alloc] initWithScheme:@"http" host:@"example.host.co

我需要检查Mac电脑上是否安装了应用程序的多个版本

我需要检查mac电脑上是否安装了多个版本的Google Chrome

使用最新版本的Google Chrome打开一个URL。

NSURL*URL=[[NSURL alloc]initWithScheme:@“http”host:@“example.host.com”path:@”/example“;
NSURL *url = [[NSURL alloc] initWithScheme:@"http" host:@"example.host.com" path:@"/example"];

CFArrayRef finds = LSCopyApplicationURLsForURL (
                                                (CFURLRef) url,
                                                kLSRolesAll
                                                ) ;// all web applications

for(int i=0;i<CFArrayGetCount(finds);i++)
{
CFURLRef appURL = CFArrayGetValueAtIndex(finds,i); 
MDItemRef item = MDItemCreateWithURL(kCFAllocatorDefault, appURL);
CFTypeRef itemVersion = MDItemCopyAttribute(item, kMDItemVersion);// version
NSLog(@"appURL %@ itemVersion %@",appURL,itemVersion);
}

//appURL file://localhost/Applications/Google%20Chrome.app/ itemVersion 30.0.1599.101
CFArrayRef finds=LSCopyApplicationURLsForURL( (CFURLRef)url, kLSRolesAll ) ;// 所有web应用程序 对于(int i=0;i
NSURL*url=[[NSURL alloc]initWithScheme:@“http”主机:@“example.host.com”路径:@”/example“];
CFArrayRef finds=LSCopyApplicationURLsForURL(
(CFURLRef)url,
kLSRolesAll
);//所有web应用程序

对于(int i=0;i使用启动服务/CFBundle按捆绑包ID进行搜索。cf&使用启动服务/CFBundle按捆绑包ID进行搜索。cf&