我正在尝试使用Objective-C创建一个在iOS设备上显示已安装应用程序的软件包ID的应用程序。
UILabel *bundleIdentifier = [[UILabel alloc]initWithFrame:CGRectMake(10,10,200,50)];
bundleIdentifier.text = [[NSBundle mainBundle] bundleIdentifier];
[self.view addSubview:bundleIdentifier];
通过在应用程序代码中使用此代码,我可以显示我正在创建的应用程序的包ID ...
如何获取其他应用的包ID?
在标题SBApplication.h中,我找到了-(NSString*)bundleIdentifier;
这有用吗?
谢谢!
答案 0 :(得分:-1)
您可以通过使用属性来了解哪些框架和捆绑包可用:
这些属性返回一个包含所有可用包/框架的数组(1) 您可以遍历数组并查找您感兴趣的包(2)
// (1) get all frameworks and bundles that seem to be available and put them in one array
NSMutableArray *bundles = [NSMutableArray new];
[bundles addObjectsFromArray:[NSBundle allFrameworks]];
[bundles addObjectsFromArray:[NSBundle allBundles]];
// (2) Loop through the array and look for the stuff you are interested in
for (NSBundle *bundle in bundles)
{
// Do whatever you want with the bundle or private frameworks.
// https://developer.apple.com/reference/foundation/nsbundle?language=objc
NSLog(@"------");
NSLog(@"%@",bundle);
NSLog(@"%@",bundle.bundleURL);
NSLog(@"%@",bundle.bundlePath);
NSLog(@"%@",bundle.bundleIdentifier);
NSLog(@"%@",bundle.infoDictionary);
NSLog(@"------");
}