Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
554 views
in Technique[技术] by (71.8m points)

objective c - programmatically identifing the iphone device

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.

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

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

please help me.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...