5
5

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.

Mac OS XやiOSアプリのプログラムからバージョン名を取得する

Last updated at Posted at 2014-08-23

バージョン名などバンドルに設定した情報を取得するときは、NSBundleのインスタンスメソッドobjectForInfoDictionaryKey:を使う。

// Objective-Cの場合
NSString *version_name = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
// Swiftの場合
let version_name = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString")

NSBundleにはinfoDictionaryという辞書を返すインスタンスメソッドがありおそらくここからも取り出せるけど(未確認)、シンプルに値を取り出すだけならobjectForInfoDictionaryKey:を使う方がスマート。

5
5
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
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?