Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define preprocessor macro to check iOS version

I use it to check iOS version, but it doesn't work:

#ifndef kCFCoreFoundationVersionNumber_iPhoneOS_5_0
#define kCFCoreFoundationVersionNumber_iPhoneOS_5_0 675.000000
#endif

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0
#define IF_IOS5_OR_GREATER(...) \
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iPhoneOS_5_0) \
{ \
__VA_ARGS__ \
}
#else
#define IF_IOS5_OR_GREATER 0
#endif

when I make

#if IF_IOS5_OR_GREATER
NSLog(@"iOS5");
#endif

nothing happens. Is something wrong here?

like image 758
Bartosz Bialecki Avatar asked Oct 20 '11 13:10

Bartosz Bialecki


People also ask

What is macro in IOS?

With Macro Control on, your Camera app displays a macro button when your iPhone is within macro distance of a subject. Tap the macro button to turn off automatic macro switching, and tap it again to turn automatic macro switching back on.


2 Answers

Much simpler:

#define IS_IOS6_AND_UP ([[UIDevice currentDevice].systemVersion floatValue] >= 6.0)
like image 105
Gowiem Avatar answered Oct 07 '22 12:10

Gowiem


#ifdef __IPHONE_5_0 

etc

Just look for that constant. All the objective c constants start with two underscores

like image 10
Joel Teply Avatar answered Oct 07 '22 11:10

Joel Teply