How to get the name of the running application in iOS

前端 未结 10 859
误落风尘
误落风尘 2020-12-25 09:28

If the application name under the icon on the home screen is \"My Awesome App\" how do you get that string within the application at runtime?

10条回答
  •  醉梦人生
    2020-12-25 09:54

    Attention:

    If you do a localizations in your app, you should use the blew code to get the true localized display name:

    Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String ?? ""
    Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String ?? ""
    

    rather than:

    Bundle.main.object(forInfoDictionaryKey: kCFBundleNameKey as String) as? String
    

提交回复
热议问题