On Sep 12, 2008, at 18:26 , Citizen wrote:
On 12 Sep 2008, at 22:06, Dave DeLong wrote:I've been looking inside NSWorkspace, NSBundle, NSApplication, NSFileWrapper, etc for some way to get the display name of an application from it's bundle identifier, but I can't find anything. Is there a way to do this? For example, if I have "com.apple.InterfaceBuilder3", I'd like to get back "Interface Builder".I've just implemented some code to do this: - (NSString *) name { NSBundle * appBundle = [NSBundle bundleWithPath:[self absolutePath]];NSString * name = [appBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"]; if (!name) name = [appBundle objectForInfoDictionaryKey:@"CFBundleName"]; // this failed for "Gimp" so... if (!name) name = [appBundle objectForInfoDictionaryKey:@"CFBundleExecutable"]; if (!name) name = [[[self absolutePath] stringByDeletingPathExtension] lastPathComponent];if (!name) name = @"unknown"; return name; } - (NSString *) absolutePath {return [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:[self bundleIdentifier]];} I don't know if the CFBundleExecutable idea is a good one or not.You could nest the conditions to make it more efficient (I just went for readability).
I think that the file manager way is the better choice because you get the localization for free... (assuming the app has a localized name).
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]