Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between these 2 macros?

Tags:

macros

iphone

What is the difference between

__IPHONE_OS_VERSION_MAX_ALLOWED

and

__IPHONE_OS_VERSION_MIN_REQUIRED

Which should I use to detect old/new SDKs, like

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_2
like image 994
cocoapriest Avatar asked Jul 16 '10 22:07

cocoapriest


1 Answers

__IPHONE_OS_VERSION_MIN_REQUIRED is set to the Deployment target, which represents the version the user must minimally run to install your app. __IPHONE_OS_VERSION_MAX_ALLOWED is set to the SDK version you're compiling against, although that doesn't mean your app won't run on newer versions though, but you can use it to check whether some OS features are available.

For instance, since iOS 3.2 we have the UIBezierPath class. If you're compiling against SDK 3.1 (to test it in the iPhone Simulator presumably), this new class is not available so the compiler will give you a warning that the class doesn't exist. Fair enough, but we don't want to comment that specific code every time we build it against the older SDK, just for a simulator test. We just want to hide these blocks of code and that's made possible by those macro's.

Please read this article on Cocoa with Love for further explanation, tips and tricks.

like image 160
Joost Avatar answered Nov 16 '22 03:11

Joost