如何使用Swift以编程方式确定最新的iOS版本? [英] How can I determine the latest iOS version programmatically using Swift?

查看:42
本文介绍了如何使用Swift以编程方式确定最新的iOS版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建一个基于Swift的iOS应用程序.

I'm currently building a Swift based iOS application.

在我的应用程序中,我想验证设备的特定安全功能.

In my application, I'd like to validate specific security features of the device.

其中之一是确保设备安装了最新的iOS版本.

One of these is to ensure that the device has the latest iOS version installed.

当然,在设备上获取当前安装的iOS版本非常简单.但是我似乎找不到任何API以编程方式确定最新的可用iOS版本.

Of course, getting the currently installed version of iOS on the device is quite simple. But I can't seem to find any API to programmatically determine what the latest available iOS version is.

是否有一些API可以做到这一点?也许我可以在Apple网站上调用一些REST API来收集这些信息?

Is there some API to do this? Or perhaps some REST API I can call on an Apple site to glean this information?

推荐答案

Apple在 http://phobos.apple.com./version 处提供了API.使用以下命令在命令行上对其进行测试:

Apple provides an API at http://phobos.apple.com./version. Test it on the command line using:

curl -L http://phobos.apple.com./version

( -L 是必不可少的,因为给定的URL重定向到其他地方)

(The -L is essential as the given URL redirects somewhere else)

响应是XML,并且您所需的信息由设备版本(例如 iPhone8,1 ")键入.

The response is XML, and the information you need is keyed by device version (eg iPhone8,1).

您可以通过使用Swift中的 sysctlbyname()来访问设备的版本..

You can access your device's version by using sysctlbyname() from Swift.

这篇关于如何使用Swift以编程方式确定最新的iOS版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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