Getting an iPhone app's product name at runtime?

前端 未结 12 2193
醉梦人生
醉梦人生 2021-01-30 19:43

How can this be achieved? I would like to get the name so i can display it within an app, without having to change it in code each time i change a name, of course.

12条回答
  •  情话喂你
    2021-01-30 20:09

    Good answers here. I would add one thing though.

    Rather than using @"CFBundleDisplayName", which has the potential to change in future, it's best to cast the string constant supplied in CFBundle.h like so:

    [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];
    

    Thus future-proofing your code.

提交回复
热议问题