2014-09-04 146 views

回答

1

有几种方法可以做到这一点 - 我通常采取除了使用NSBundle最短路线CFBundleversion

NSBundle *appBundle = [NSBundle bundleWithPath:appPath]; 
NSString *bundleVersion = [appBundle objectForInfoDictionaryKey:@"CFBundleVersion"]; 
1

一旦你有了应用程序的完整路径,你可以阅读Contents/Info.plist文件并查看CFBundleShortVersionString的值。

事情是这样的:

NSString *appPath = [NSWorkspace fullPathForApplication:appName]; 
NSString *plistPath = [appPath stringByAppendingPathComponent:@"Contents/Info.plist"]; 
NSDictionary *plist = [NSDictionary dictionaryWithContentsOfFile:plistPath]; 
NSString *version = plist[@"CFBundleShortVersionString"]; 
+0

很好的答案最好的,我得到了更多比我想要的。 – Ping 2014-09-05 14:02:53

相关问题