以编程方式识别iphone设备 [英] programmatically identifing the iphone device

查看:89
本文介绍了以编程方式识别iphone设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想识别安装我的应用程序的设备。
这意味着,当我在iphone上安装应用程序时,它应该告诉我设备信息。
信息就像,设备是2G,3G或3GS。

I want to identify the device on which my application is installed. That means, when I install the app on the iphone, it should tell me the device information. The information is like, the device is 2G, 3G or 3GS.

目前我只获得设备的型号,名称,系统名称,systemVersion。

Currently I am getting only model, name, systemName, systemVersion of the device.

我想知道该设备是2G,3G或3GS。

I want to know the device is 2G , 3G or 3GS.

请帮助我。

推荐答案

在过去的Mac编程历史中,这一直被认为是错误的问题。

In the past history of Mac programming, this was always considered the wrong question.

您真正需要知道的是更具体的信息。为代码中的每个行为决策提出一个更狭隘的问题。例如,您可能需要知道设备是否具有GPS。另一个原因是你不应该根据它的型号来决定如何使用OpenGL堆栈,而是根据提供的OpenGL功能/扩展信息来决定。

What you really need to know is a more specific piece of information. Ask a much more narrow question for each behavioral decision in your code. For example, you may need to know if the device has GPS or not. Another is that you shouldn't decide how to use the OpenGL stack based on what model device it is, but rather on the OpenGL capabilities/extensions information that is provided.

您现在获得的信息来自UIDevice,这是一个不幸的设计不佳的API。它以最糟糕的格式向您提供完全错误的信息 - 字符串。

The information you're getting now is from UIDevice, which is an unfortunately poorly designed API. It provides you with exactly the wrong information in the worst possible format -- strings.

Erica Sadun对UIDevice有一个可能有用的扩展这里。它只是 sysctlbyname(hw.machine,...)的包装器。每个型号的属性都不同。

Erica Sadun has an extension to UIDevice that may be useful here. It's just a wrapper for sysctlbyname("hw.machine", ...). This property is different for each model.

但同样,这通常是错误的问题。

But again, this is usually the wrong question.

这篇关于以编程方式识别iphone设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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