这两个宏有什么区别

这两个宏有什么区别

本文介绍了这两个宏有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么区别

我应该使用哪个来检测旧的/新的SDK,例如

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

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_2


推荐答案

__ IPHONE_OS_VERSION_MIN_REQUIRED 设置为部署目标,表示用户必须最低限度运行才能安装应用程序的版本。 __ IPHONE_OS_VERSION_MAX_ALLOWED 设置为您正在编译的SDK版本,但这并不意味着您的应用程序不会在较新版本上运行,但您可以使用它来检查某些操作系统功能是否可用。

__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.

例如,自iOS 3.2起,我们有 UIBezierPath 类。如果您正在针对SDK 3.1进行编译(大概是在iPhone模拟器中测试它),则此新类不可用,因此编译器会向您发出该类不存在的警告。很公平,但我们不希望每次针对较旧的SDK构建它时对该特定代码进行评论,仅用于模拟器测试。我们只想隐藏这些代码块,这些代码块可以通过那些宏来实现。

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.

这篇关于这两个宏有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 10:41