26

I have made an application and I have installed it on my iphone, but I want to check my application bundle version programatically. How can that be done?

Dan
  • 12,157
  • 12
  • 50
  • 84
MD.
  • 1,131
  • 4
  • 18
  • 28

2 Answers2

72
NSString *versionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey];
Vladimir
  • 170,431
  • 36
  • 387
  • 313
16

Here are some macros:

#define BUNDLE_VERSION_EQUAL_TO(v)                  ([[[NSBundle mainBundle]     objectForInfoDictionaryKey:(NSString*) kCFBundleVersionKey] compare:v  options:NSNumericSearch] == NSOrderedSame)
#define BUNDLE_VERSION_GREATER_THAN(v)              ([[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*) kCFBundleVersionKey] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define BUNDLE_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*) kCFBundleVersionKey] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define BUNDLE_VERSION_LESS_THAN(v)                 ([[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*) kCFBundleVersionKey]  compare:v options:NSNumericSearch] == NSOrderedAscending)
#define BUNDLE_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*) kCFBundleVersionKey] compare:v options:NSNumericSearch] != NSOrderedDescending)
Colin Phillips
  • 1,001
  • 1
  • 10
  • 11