Get Application Name

If you ever need to get the name of your application in code, for example, to display the application name across a navigation bar, it’s as near as the bundle for your application.

The code to get the name is as simple as this:

[[[NSBundle mainBundle] infoDictionary]   objectForKey:@"CFBundleName"];

The breakdown is as follows:


NSBundle mainBundle
creates a bundle object that maps to the directory where the application lives.

infoDictionary
returns a dictionary that contains the contents of the above bundles Info.plist

objectForKey:@”CFBundleName”
will return the value for specified key, in our example, the name of the application.

Read more about Information Property Lists and Key Values

  1. Hello,

    To my mind the right key is CFBundleDisplayName

    • Hey Bruno, thanks. I looked up both keys in the Apple docs, for CFBundleName is states: “If you localize this key, you should also include the key “CFBundleDisplayName.” For CFBundleDisplayName “If you localize this key, you should also include a localized version of the CFBundleName key. If you do not intend to localize your bundle, do not include this key in your Info.plist file.” So I guess it really depends on whether or not the app is localized.

  2. infoDictionary returns a dictionary that contains the contents of the above bundles Info.plist

    Yes you are right i did try it and works

Comments are closed.