【问题标题】:Access any apps bundle identifier访问任何应用程序包标识符
【发布时间】:2016-04-30 22:01:57
【问题描述】:

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

【问题讨论】:

    标签: macos path bundle-identifier nsrunningapplication


    【解决方案1】:

    使用核心基础函数CFBundleGetIdentifier

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

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

    【讨论】:

      猜你喜欢
      • 2017-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-29
      • 2011-11-16
      相关资源
      最近更新 更多