简体   繁体   English

这两个宏有什么区别?

[英]What is difference between these 2 macros?

What is the difference between 有什么区别

__IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_OS_VERSION_MAX_ALLOWED

and

__IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_OS_VERSION_MIN_REQUIRED

Which should I use to detect old/new SDKs, like 我应该使用哪个来检测旧的/新的SDK,比如

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_2

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

For instance, since iOS 3.2 we have the UIBezierPath class. 例如,从iOS 3.2开始,我们就有了UIBezierPath类。 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. 如果你正在编译SDK 3.1(大概是在iPhone模拟器中测试它),这个新类是不可用的,所以编译器会给你一个警告,表明该类不存在。 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. 很公平,但我们不希望每次针对旧版SDK构建它时都会评论该特定代码,仅用于模拟器测试。 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. 请阅读这篇关于Cocoa with Love的文章,以获得进一步的解释,提示和技巧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM