iOS アプリケーションで html の形式で About を表示しています。About.html もアプリケーションと一緒にバンドルされています。
バージョンを変更するたびにHTMLを手動で編集する必要がないように、About htmlページにアプリケーションのバージョンを自動的に表示したいと考えています。
現在、私がやっていることは次のとおりです:
私は html を次のように作成して<b>Version %@</b>
います
NSString* aboutFilePath = [[NSBundle mainBundle] pathForResource:@"About" ofType:@"html"];
NSString* htmlStr = [NSString alloc] initWithContentsOfFile:aboutFilePath encoding:NSUTF8StringEncoding error:nil];
NSString* formattedStr = [NSString stringWithFormat:htmlStr, [self appNameAndVersionNumberDisplayString];
[self.webView loadHTMLString:formattedStr baseURL:nil];
- (NSString *)appNameAndVersionNumberDisplayString {
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *appDisplayName = [infoDictionary objectForKey:@"CFBundleDisplayName"];
NSString *majorVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
NSString *minorVersion = [infoDictionary objectForKey:@"CFBundleVersion"];
return [NSString stringWithFormat:@"%@, Version %@ (%@)",
appDisplayName, majorVersion, minorVersion];
}
それを行うのは良い方法ですか、それともそれを達成するためのより良い方法はありますか?