NSString *CurPath = [[NSBundle mainBundle] bundlePath];
NSString *xmlPath = [CurPath stringByAppendingPathComponent:@"/Contents/Info.plist"];
NSMutableDictionary* dict = [[ NSMutableDictionary alloc ] initWithContentsOfFile:xmlPath];
NSString* Ver = [dict objectForKey:@"CFBundleShortVersionString"];
NSDictionary * info = [[NSBundle mainBundle] infoDictionary];
[self.window setTitle:[info objectForKey:(NSString *)kCFBundleExecutableKey]];
本文介绍了使用Swift语言从应用程序的Info.plist文件中读取版本信息的方法。通过NSBundle获取主包路径,然后追加Info.plist路径,使用NSMutableDictionary初始化并读取文件内容,最后获取CFBundleShortVersionString键对应的版本号。
759

被折叠的 条评论
为什么被折叠?



