cocoa – 按标识符定位包

我想从任意包标识符创建一个
例如com.apple.iokit.IOStorageFamily

假设捆绑ID,这不是一件不合理的事情
是唯一的,但明显的代码不起作用:

Nsstring* bID = @"com.apple.iokit.IOStorageFamily";
NSBundle* bundle = [NSBundle bundleWithIdentifier:bID];

代码仅适用于您已加载的捆绑包
(你好,鸡肉和鸡蛋问题),事实上,你有
了解比标识符更多的东西
在你做任何事之前.对于上述风格的ID
我将最后一个组件弄清楚并将其转换为
/System/Library/Extensions/IOStorageFamily.kext
然后我按路径加载.

这是最先进的技术还是有更普遍的方式?

解决方法

就在最近 Andrew Myrick answered a similar question在darwin-dev邮件列表上:

KextManagerCreateURLForBundleIdentifier()
in <IOKit/kext/KextManager.h> may be
of use,though I believe it only works
for kexts that are either 1) loaded,
or 2) in /S/L/E/. Here is the SNow
Leopard headerdoc:

06000

Note that prior to SNow Leopard,it
may only work for kexts in /S/L/E; the
API existed,but there was no
headerdoc describing its behavior.

对我来说,这在Mac OS X 10.5上运行得非常好.

相关文章

我正在用TitaniumDeveloper编写一个应用程序,它允许我使用Ja...
我的问题是当我尝试从UIWebView中调用我的AngularJS应用程序...
我想获取在我的Mac上运行的所有前台应用程序的应用程序图标....
我是一名PHP开发人员,我使用MVC模式和面向对象的代码.我真的...
OSX中的SetTimer在Windows中是否有任何等效功能?我正在使用...
我不确定引擎盖下到底发生了什么,但这是我的设置,示例代码和...