如何使用宏检测iPhone OS版本 [英] How to detect iPhone OS version using macros

查看:98
本文介绍了如何使用宏检测iPhone OS版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用中检测iPhone OS版本。我尝试过使用检测代码,但建议使用宏。有人经验,你可以发布示例代码,以及使用什么库。

I would like to detect iPhone OS version in my app. I have tried using detection code but was advised to use macros. Does someone experience, can you post sample code, and what library to use.

推荐答案

我不确定你是什么宏建议使用。我一直认为找到版本号的标准方法是使它与未来和以前的版本兼容是使用

I am not certain what macros you are being advised to use. I always thought that the standard way to find the version number so that it will be compatiable with future and previous versions was to use

NSString* versionNumber = [[UIDevice currentDevice] systemVersion]

将其作为NSString,例如@ 2.0或@2.2.1

which gives it as a NSString such as @"2.0" or @"2.2.1"

有一些Version常量描述了正在使用的Foundation类的版本,其中 NSFoundationVersionNumber 但我不确定这在旧版和未来代码中的可靠性。

There are the Version constants that describe the version of Foundation classes being used, with NSFoundationVersionNumber but I am uncertain of how reliable this will be in older and future code.

这篇关于如何使用宏检测iPhone OS版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆