

至於要如何使用程式碼取得 Info.plist 中這些 Key 的 Value 呢?可以參考以下程式碼。
//自行定義的函式,用來讀取info.plist的版本 - (void)getVersion { NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]; versionLabel.text = version; [version release]; }
//自行定義的函式,用來讀取info.plist的專案名稱 - (void)getName { NSString *name = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]; nameLabel.text = name; [name release]; }
上面示範了從 Info.plist 中取得版本已經專案名稱的方法,當然其他欄位的數值取得方法也是以此類推,下列我們也列出幾個常用的 Key 與 Value 的寫法。
Standard Keys CFBundleDevelopmentRegion CFBundleExecutable CFBundleGetInfoString CFBundleIdentifier CFBundleDisplayName CFBundleShortVersionString CFBundleSignature CFBundleVersion NSPrincipalClass Values ${EXECUTABLE_NAME} ${SANDVOX_VERSION} ${SVN_VERSION} ${PROJECT_NAME}
沒有留言:
張貼留言