How to tell if your code is running on an iPhone or an iPhone3G?

前端 未结 3 361
醉梦人生
醉梦人生 2020-12-05 07:35

I am trying to determine if my code is running on an iPhone or an iPhone3G. My first try was to use the UIDevice class in UIKit, but both iPhone and iPhone3G return the sam

相关标签:
3条回答
  • 2020-12-05 08:01

    I'm not an iPhone developer but checking for the underlying platform instead of platform capabilities is almost always the wrong choice. If the iPhone gains the functionality you need, you will still fail to run. There's also a chance you'll make the wrong decision on the next iPhone 4.0 (or whatever it is called).

    0 讨论(0)
  • 2020-12-05 08:02

    My guess is that there is functionality on the iPhone that is not on the iPhon3G that your software is concerned with. My Suggestion is to query about that specific hardware instead of changing the software behaviour based on the platform.

    For example. instead of checking for the availibility of GPS by asking is this an iPhone or iPhone3G query about the availability of the GPS and go from there. That way your code will work on any platform (iphone/ipod touch/iphone 3G)

    0 讨论(0)
  • 2020-12-05 08:16

    The iPhone runs OS X. Here's how to determine your hardware platform on a Macintosh desktop. Here's how on an iPhone. It's the same exact thing.

    In short, sysctlbyname("hw.machine", str, sz, 0, 0) will write the platform name into str. This happens to be "iPhone1,1" or "iPhone1,2" for the iPhone and iPhone 3G respectively.

    0 讨论(0)
提交回复
热议问题