在 运行 时间内获取并设置我的应用程序的捆绑标识符

Get and set bundle-idenfitier of my app during run time

我正在尝试在 运行 时间获取我的应用程序的 CFBundleIdentifier 值。使用这可能吗?我搜索了 NSApplication class 参考资料,但我找不到能给我包标识符的东西。

我也有兴趣在 运行 时间内设置 bundle-identifier,可以吗?

谢谢

PS:我知道如果您不知道上下文,这是一个奇怪的问题,因为应用程序只有一个包标识符。然而,用户通过他们的 .app 和 shell 命令启动我的应用程序(Firefox 的构建),该命令为其提供 .app 的包标识符。有关上下文的更多详细信息:ask.m.o :: OSX - How to control the bundle-identifier and file-data :: _CFURLString [[NSBundle mainBundle] bundleIdentifier] 没有给我启动 .app 的包标识符。我也尝试遍历所有 [[NSBundle allBundles] bundleIdentifier] 但它也不在那里。

无法更改捆绑包标识。即使你做了一些讨厌的挖掘,它也会被应用商店拒绝。

获取方法:

[[NSBundle mainBundle] bundleIdentifier];