14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

info.plistに設定値の取得方法

Posted at

info.plistに設定されている値を取得するには

NSString *bundlePackageType = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundlePackageType"];
NSString *bundleShortVersionString = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

のように[[[NSBundle mainBundle] infoDictionary] objectForKey:@"key名"]で取得できます。info.stringでローカライズしている場合に環境に合わせた値を取得するには

//info.plist:CFBundleDisplayName="Sample"
//info.string(japanese):CFBundleDisplayName = "サンプル";

//info.plistに設定された値が取得される(Sample)
NSString *bundleDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
  
//info.stringに設定された値が取得される(サンプル)
NSString *localizedBundleDisplayName = [[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"];

というように[[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"key名"]で取得します。

14
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?