0

对于我的应用程序,我让用户为其计算机的特定应用程序选择路径。从那个路径(即/Applications/Itunes.app)我想获取包标识符,并NSRunningApplication从中创建一个实例([NSRunningApplication runningApplicationsWithBundleIdentifier:(nonnull NSString *)];我将如何获取这个包标识符?

4

1 回答 1

1

使用核心基础函数CFBundleGetIdentifier

从包的路径创建包引用CFURLCreateFromFileSystemRepresentation并调用CFBundleCreate

url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, bundlePath, bundleLength, true);
bundle = CFBundleCreate(kCFAllocatorDefault, url);

CFStringRef identifier = CFBundleGetIdentifier(bundle)
于 2016-01-25T11:55:38.413 回答