【发布时间】:2010-10-15 20:06:53
【问题描述】:
我正在尝试确定我的代码是在 iPhone 还是 iPhone3G 上运行。我的第一次尝试是在 UIKit 中使用 UIDevice 类,但 iPhone 和 iPhone3G 都返回相同的响应:
NSLog([[UIDevice currentDevice] name]); // Name of the phone as named by user
NSLog([[UIDevice currentDevice] uniqueIdentifier]); // A GUID like string
NSLog([[UIDevice currentDevice] systemName]); // "iPhone OS"
NSLog([[UIDevice currentDevice] systemVersion]); // "2.2.1"
NSLog([[UIDevice currentDevice] model]); // "iPhone" on both devices
NSLog([[UIDevice currentDevice] localizedModel]); // "iPhone" on both devices
这些是 UIDevice 允许您查询的唯一参数。
我在 Foundation Framework 中看了一些,但还没有找到合适的调用。
我确定我可以查询某些硬件(例如位置服务中的某些内容),但这似乎是一种 hack。有谁知道确定这一点的简单方法?
【问题讨论】: