Is it possible to access the app version that I specify in the xcode project setting from within the application?
I'm trying to create an auto-updating "About" view controller, and it would be nice to receive bug reports listing the version of the app.
I know this can be done with built-in constant, but I'm wandering if there's a better way.
Thank you!
You can read you Info.plist in your main bundle for the according key.
Sample code:
NSBundle *bundle = [NSBundle mainBundle];
NSString *infosPath = [bundle pathForResource:@"Info" ofType:@"plist"];
NSDictionary *infosDict = [[NSDictionary alloc] initWithContentsOfFile:infosPath];
NSLog(@"CFBundleVersion : %@" , [infosDict valueForKey:@"CFBundleVersion"]);
I just tested this code and its working fine. Do a right-clik on you Info.plist to display raw key names.
Also, I was testing this code with a plist with spaces in its names, which gave me 'null' for the infosPath. Deleting the space solves the problem.