运行时与编译时 iPhone 版本检查

发布于 2024-11-19 06:28:22 字数 1011 浏览 6 评论 0原文

运行时(例如,[[UIDevice currentDevice] systemVersion])和编译时(例如,__IPHONE_OS_VERSION_MIN_REQUIRED 检查)之间有什么区别?你什么时候应该一个比另一个?

__IPHONE_OS_VERSION_MIN_REQUIRED 只是构建设置中设置的变量吗?

我已阅读如何定位特定 iPhone 版本? 以及下面列出的其他相关问题。

但是,我刚刚注意到当我构建时 __IPHONE_OS_VERSION_MIN_REQUIRED = 30200使用 Xcode 4 在 iPhone (4.3.1) 上运行。为什么?

当您向 Apple 提交代码时,他们是否会为现有的每个 iPhone 版本编译一个版本,并相应地设置 __IPHONE_OS_VERSION_MIN_REQUIRED ?

这样,您就可以检查 __IPHONE_OS_VERSION_MIN_REQUIRED,并了解运行该代码的 iOS 版本。

相关问题:

What's the difference between run-time, e.g., [[UIDevice currentDevice] systemVersion], and compile-time, e.g., __IPHONE_OS_VERSION_MIN_REQUIRED checking? When should you one over the other?

Is__IPHONE_OS_VERSION_MIN_REQUIRED just a variable set in Build Settings?

I've read the answers to How to target a specific iPhone version? and other related questions listed below.

But, I just noticed that __IPHONE_OS_VERSION_MIN_REQUIRED = 30200 when I build & run on iPhone (4.3.1) with Xcode 4. Why?

When you submit your code to Apple, do they compile a version of it for each version of the iPhone that exists, setting __IPHONE_OS_VERSION_MIN_REQUIRED accordingly?

That way, you could inspect __IPHONE_OS_VERSION_MIN_REQUIRED, and know what iOS version is running the code.

Related Questions:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

独木成林 2024-11-26 06:28:22

__IPHONE_OS_VERSION_MIN_REQUIRED 确实只是一个构建设置,您可以在编译前在预处理器中使用它来修改代码。不,Apple 不会为每部 iPhone 编译您的代码。他们不能,因为您没有给他们代码。例如,您可以使用编译时检查来确定是否需要编译代码以模拟旧操作系统版本中的新功能。但是,您可以使用运行时版本检查来确定是否应该使用该功能的内置版本或模拟版本。

例如,4.0 中添加了 iAd。您当前支持 4.0 及更高版本,但计划将来添加对 3.2 的支持。您编写代码以在旧版本中显示其他广告,使用运行时检查来确定是否应该使用 iAds 或其他广告,但您不希望在应用程序的其余部分为 3.2 做好准备之前将其出现在任何版本中,因为它将使您的应用程序更大。您可以使用编译时检查,以便预处理器将该代码排除在您的版本之外。通过使用最低版本宏,您可以通过更改最低版本构建设置轻松地将代码添加到您的版本中。

__IPHONE_OS_VERSION_MIN_REQUIRED is indeed just a build setting, which you can use in the preprocessor to modify code before compilation. No, Apple doesn't compile your code for each iPhone. They can't, since you don't give them the code. You can use compile time checking to determine, for example, if you need to compile code to emulate a new feature in older OS versions. However, you use runtime version checking to determine whether you should use the built in or emulated version of that feature.

For example, iAds were added in 4.0. You currently support 4.0 and later, but plan on adding support for 3.2 in the future. You make code to display other ads in older versions, using runtime checking to determine whether you should use iAds or other, but you don't want it to be in any releases until the rest of the application is ready for 3.2, since it will make your application larger. You use compile time checking so that the preprocessor leaves that code out of your releases. By using the minimum version macro, you can easily add the code to your release by changing the minimum version build setting.

此刻的回忆 2024-11-26 06:28:22

是的,__IPHONE_OS_VERSION_MIN_REQUIRED 只是“构建设置”下“iOS 部署目标”的值。确保选择正确的目标,而不是项目。

并且,__IPHONE_OS_VERSION_MAX_ALLOWED 对应于“Base SDK”构建设置。

Yes, __IPHONE_OS_VERSION_MIN_REQUIRED is just the value for "iOS Deployment Target" under "Build Settings." Make sure the correct target, not the project, is selected.

And, __IPHONE_OS_VERSION_MAX_ALLOWED corresponds to the "Base SDK" build setting.

她如夕阳 2024-11-26 06:28:22

开发人员将使用的编译和运行时或编程词。所以编译时最好的例子就是代码的编写时间,比如导入语法、声明属性和方法。而ARC就是编译时编程。而开发者写完代码之后要执行的程序来到RUNTime,就称为运行时。此时,代码将被编译,并将面临运行时错误,例如程序崩溃,并关闭程序的意外行为。

请查找以下网址了解更多详细信息

http://pc.net/helpcenter/answers/compile_time_vs_runtime

The Compile and Run time or programing words which will be used by the developer. So the best example of compile time is the writing time of the code like importing syntax and declaring properities and methods.and ARC is the compile time programing. And coming to RUNTime after writing the code by the developer is going to execute the program is called runtime. In this time the code will be compiled and will face run time errors like crashing programs and fourse closes unexpected behaviour of the program like that.

Please find the below url For more details

http://pc.net/helpcenter/answers/compile_time_vs_runtime

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文