我试图确定我的代码是在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
Run Code Online (Sandbox Code Playgroud)
这些是UIDevice允许您查询的唯一参数.
我在Foundation Framework中看了一下,但还没有找到合适的电话.
我敢肯定有一些我可以查询的硬件(例如位置服务中的东西),但这似乎是一个黑客.有谁知道确定这个的简单方法?
我不是iPhone开发人员,但检查底层平台而不是平台功能几乎总是错误的选择.如果iPhone获得了您所需的功能,您仍然无法运行.你也有可能在下一代iPhone 4.0(或其他任何名称)上做出错误的决定.
归档时间: |
|
查看次数: |
5134 次 |
最近记录: |