programmatically identifing the iphone device

前端 未结 3 1740
滥情空心
滥情空心 2020-12-18 03:21

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 informat

3条回答
  •  执念已碎
    2020-12-18 03:48

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

    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.

    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 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.

提交回复
热议问题