2014-09-04 208 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

相關問題