Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using CFBundleGetVersionNumber

Tags:

xcode

nsbundle

I want to get the version number from info.plist using:

NSString *version = (NSString *)CFBundleGetVersionNumber(CFBundleGetMainBundle());

That doesn't give me the string value from Bundle Version that I expect.

This does give me the string I expect:

NSString *version = (NSString *)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey);

I'd like to know how to get the first form to work since it looks like it's the preferred way to get the version from info.plist.

Here is how I'm using the result:

htmlAbout = [htmlAbout stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"[version]"] withString:version];

I'm working in Xcode 4.1

Thanks

like image 872
Jon D. Burgermeister Avatar asked Sep 07 '25 10:09

Jon D. Burgermeister


1 Answers

a serious error in conversion exists in your program: CFBundleGetVersionNumber returns UInt32, which is not convertible via typecast to NSString (or any objc type).

like image 88
justin Avatar answered Sep 09 '25 19:09

justin