We all like to put the current application version number in an “about” screen somewhere for users to reference. It’s a pain, however, to have to update that screen every time we do a release as well as the version in the target configuration for the bundle. So why not pull the version number from the bundle? Here’s how to do it:
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleVersionKey];
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
Just put this version number in your label programatically and you’re set! Since my About screen is in a nib/xib, I set the label text to “Version x.x” so I would understand the label isn’t static next time I look at the screen in Interface Builder.
— UPDATED 3/9/2012
I updated this post with a recent change to the way version numbers work. Not sure if this was an advertised change by Apple, but this should fix any issues you have.