通过标识符查找包
我想从任意包标识创建一个包
例如com.apple.iokit.IOStorageFamily
I want to create a bundle from an arbitrary bundle identifier
e.g. com.apple.iokit.IOStorageFamily
这并不是一件不合理的事情,因为应该假定捆绑包ID
唯一,但是明显的代码不起作用:
It's not an unreasonable thing to do as bundle IDs are supposed
to be unique, however the obvious code does not work:
NSString* bID = @"com.apple.iokit.IOStorageFamily";
NSBundle* bundle = [NSBundle bundleWithIdentifier:bID];
此代码仅适用于已加载的包
(您好,鸡肉和鸡蛋问题),实际上,您有
了解有关标识符的更多信息
在您可以做任何事情之前.对于上面的ID
我grep出了最终的组件并将其转化为/System/Library/Extensions/IOStorageFamily.kext
然后我按路径加载.
This code only works for bundles you've already loaded
(hello, chicken and egg problem), and in fact, you have
to know a little more than you'd like about the the identifier
before you can do anything. For the above style of ID
I grep out the final component and tranform it into/System/Library/Extensions/IOStorageFamily.kext
which I then load by path.
这是最新技术吗?还是有更通用的方法?
Is this the state of the art or is there a more general way?