Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CFBundleDisplayName returns 'null'

I'm trying to get app name to use as the NavController title, but whatever I do I can't get CFBundleDisplayName value. It returns 'null'.

this is the code I'm using

[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]

Checked bundles = there is one only. Xcode5 / dev target is iOS5. I haven't checked on a device though. Using Simulator.

Thanks!

like image 488
Nutuz Avatar asked Sep 24 '13 18:09

Nutuz


3 Answers

Try this code to get app name

   NSString *appName =      [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleNameKey];
like image 160
jeyachandran Avatar answered Oct 22 '22 01:10

jeyachandran


Swift extension, tested with iOS 9:

extension UIApplication {

    static var applicationName: String {
        let mainBundle = NSBundle.mainBundle()
        let key = String(kCFBundleNameKey)
        let value = mainBundle.objectForInfoDictionaryKey(key) as? String
        return value ?? ""
    }

}
like image 29
Rudolf Adamkovič Avatar answered Oct 22 '22 00:10

Rudolf Adamkovič


Goto project setting & set display name, Then you can check.

like image 34
Digvijay Gida Avatar answered Oct 22 '22 00:10

Digvijay Gida