• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: App name from Bundle Identifier?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: App name from Bundle Identifier?


  • Subject: Re: App name from Bundle Identifier?
  • From: Jason Coco <email@hidden>
  • Date: Fri, 12 Sep 2008 20:46:56 -0400


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).

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: App name from Bundle Identifier?
      • From: Dave DeLong <email@hidden>
References: 
 >App name from Bundle Identifier? (From: Dave DeLong <email@hidden>)
 >Re: App name from Bundle Identifier? (From: Citizen <email@hidden>)

  • Prev by Date: Re: clearing NSView outside of drawRect:
  • Next by Date: Re: when should my NSWindowController be released?
  • Previous by thread: Re: App name from Bundle Identifier?
  • Next by thread: Re: App name from Bundle Identifier?
  • Index(es):
    • Date
    • Thread