如何检测用户在Cocoa中是否有应用 [英] how to detect if user has an app in Cocoa
本文介绍了如何检测用户在Cocoa中是否有应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检测用户是否有应用程序,例如mac的echofon或twitter,或者用户是否有页面或textmate?有什么建议吗?
How can I detect if user has an app, like echofon or twitter for mac or if user has pages, or textmate? Any suggestions?
推荐答案
使用NSWorkspace的fullPathForApplication:获取应用程序的分发包路径.如果该方法返回nil,则说明未安装该应用程序.例如:
Use NSWorkspace's fullPathForApplication: to get an application's bundle path. If that method returns nil, the app is not installed. For example:
NSString *path = [[NSWorkspace sharedWorkspace] fullPathForApplication:@"Twitter"];
BOOL isTwitterInstalled = (nil != path);
URLForApplicationWithBundleIdentifier是您可以使用的另一种方法.
URLForApplicationWithBundleIdentifier is another method you may use.
这篇关于如何检测用户在Cocoa中是否有应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文