デバイスにインストールされているアプリのバンドル ID のリストがあり、アプリ名を取得したいと考えています。ソリューションは、jail で壊れていないデバイスで動作するはずです。アプリはアプリ ストアに掲載されないため、アプリの拒否は成立しません。
アプリストアにある場合、アプリの詳細情報を返すこのソリューションを見つけました。 http://itunes.apple.com/lookup?bundleId=com.bundle.id
デバイスにインストールされているアプリのバンドル ID のリストがあり、アプリ名を取得したいと考えています。ソリューションは、jail で壊れていないデバイスで動作するはずです。アプリはアプリ ストアに掲載されないため、アプリの拒否は成立しません。
アプリストアにある場合、アプリの詳細情報を返すこのソリューションを見つけました。 http://itunes.apple.com/lookup?bundleId=com.bundle.id
ほとんどの場合、これで取得できます...
NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleNameKey];
編集:
すべてのアプリで検索したいAS。
NSString *appName = [[NSBundle bundleWithIdentifier:@"BundleIdentifier"] objectForInfoDictionaryKey:(id)kCFBundleExecutableKey];
NSLog(@"AppName: %@",appName);
これでうまくいくはずです。
NSBundle *bundle = [NSBundle bundleWithIdentifier:@"yourBundleIdentifier"];
NSString *appName = [bundle objectForInfoDictionaryKey:@"CFBundleExecutable"];
- (NSString *)titleOfAppWithBundleIdentifier:(NSString *)bundleIdentifier {
NSBundle *bundle = [NSBundle bundleWithIdentifier:bundleIdentifier];
return [bundle objectForInfoDictionaryKey:@"CFBundleExecutable"];
}
バンドル ディクショナリを次のように設定します。
NSDictionary *bundleInfo = [[NSBundle mainBundle] infoDictionary];
NSString *appName = [bundleInfo objectForKey:@"CFBundleDisplayName"];
そして、ここにbundleInfo
ダンプされます:
{
BuildMachineOSBuild = ...;
CFBundleDevelopmentRegion = ...;
CFBundleDisplayName = ...;
CFBundleExecutable = ...;
CFBundleIcons = {
CFBundlePrimaryIcon = {
CFBundleIconFiles = (
"AppIcon29x29.png",
"AppIcon29x29@2x.png",
"AppIcon40x40@2x.png",
"AppIcon57x57.png",
"AppIcon57x57@2x.png",
"AppIcon60x60@2x.png",
"AppIcon60x60@3x.png"
);
UIPrerenderedIcon = 1;
};
};
CFBundleIdentifier = ...;
CFBundleInfoDictionaryVersion = ...;
CFBundleInfoPlistURL = ...;
CFBundleName = ...;
CFBundleNumericVersion = 0;
CFBundlePackageType = APPL;
CFBundleShortVersionString = ...;
CFBundleSignature = "????";
CFBundleSupportedPlatforms = (
iPhoneOS
);
CFBundleVersion = "1.0.11";
DTCompiler = ...;
DTPlatformBuild = ...;
DTPlatformName = iphoneos;
DTPlatformVersion = "8.3";
DTSDKBuild = ...;
DTSDKName = "iphoneos8.3";
DTXcode = ...;
DTXcodeBuild = ...;
LSRequiresIPhoneOS = 1;
MinimumOSVersion = "5.1";
UIBackgroundModes = (
...,
...
);
UIDeviceFamily = (
1
);
UILaunchImageFile = LaunchImage;
UILaunchImages = (
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = ...;
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 568}";
}
);
UIMainStoryboardFile = Main;
UIRequiredDeviceCapabilities = (
armv7
);
UISupportedInterfaceOrientations = (
UIInterfaceOrientationPortrait
);
UIViewControllerBasedStatusBarAppearance = 0;
}
ローカライズされたバンドルの表示名を取得する場合は、次を使用しますlocalizedInfoDictionary
。
NSString *appName = [[NSBundle mainBundle] localizedInfoDictionary][@"CFBundleDisplayName"];
NSString *appName = [[bundleID componentsSeparatedByString:@"."] lastObject];
bundleID がリバース DNS 形式であると仮定します。