2010-04-17 7 views

Respuesta

73
NSString *versionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey]; 
+0

¿Cómo se podría hacer una macro de esto? – Rits

+1

#define APP_VERSION [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString *) kCFBundleVersionKey]; – powerj1984

+4

sin punto y coma al final de la macro. y probablemente debería llamarse BUNDLE_VERSION. –

16

Estas son algunas 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) 
Cuestiones relacionadas