I’m currently working on an application that will need to know what version of the app is currently running. For instance, when I release version 1.2 of the app, I may need to update files that were left behind by version 1.1, but only do the update one time – the first time version 1.2 is ever launched.
I puzzled over how to detect the current version of my running app at runtime for a bit, and after digging around in the SDK documentation, I discovered that you can get access to the contents of the info.plist file that is used by your application bundle. All you have to do is ask the bundle to pretty please tell you the value of the bundle version.
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSLog(@"Starting application database handler. Detected app version %@", appVersion);