Technical Q&A QA1544

Obtaining the localized application name in Cocoa

Q:  How can I get the localized name of my Cocoa application?

A: There are several different versions of the application name, all of which are readily available as an NSString. Depending on what you need, you can use one of the following approaches.

Using kCFBundleNameKey

Use the kCFBundleNameKey key, which specifies your application's bundle name. It is your app's canonical short name and is used by the About window and main menu. Add this key to your InfoPlist.strings file before attempting to use it as shown in Listing 1. See Localizing Property List Values for more information about InfoPlist.strings files.

Listing 1  Obtaining the application's bundle name using kCFBundleNameKey.

NSString *name = [NSBundle mainBundle].localizedInfoDictionary[(NSString *)kCFBundleNameKey];


Use the CFBundleDisplayName key, which specifies your app's display name. It is typically longer and is used by the Finder to display the bundle. Add this key to your InfoPlist.strings file before attempting to use it as shown in Listing 2.

Listing 2  Obtaining the application's bundle display name using CFBundleDisplayName.

NSString *name = [NSBundle mainBundle].localizedInfoDictionary[@"CFBundleDisplayName"];

Using NSProcessInfo

Use NSProcessInfo' s processName to fetch the name of your process.

Listing 3   Acquiring the process name using NSProcessInfo.

 NSString *name = [NSProcessInfo processInfo].processName;

Using NSRunningApplication

Use NSRunningApplication's localizedName to fetch your app's localized name. This approach returns the localized value of CFBundleDisplayName if it exists, falls back on the value of CFBundleName otherwise.

Listing 4  Obtaining the localized app name using NSRunningApplication.

NSString *name = [NSRunningApplication currentApplication].localizedName;

Using NSFileManager

The better approach is to use NSFileManager's displayNameAtPath: method that will return the localized display name if it exists, fall back on the bundle name if it does not, and will even reflect a renaming of the application by the user. See Files and Directories Can Have Alternate Names for more information.

Document Revision History


Editorial update.


Fixed typo in code listing 5. Added information about NSRunningApplication for Snow Leopard (code listing 4)


New document that describes how to obtain several versions of the application name in Cocoa.