检测特定的iPhone / iPod touch型号

编程入门 行业动态 更新时间:2024-10-25 08:28:04
本文介绍了检测特定的iPhone / iPod touch型号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

可能重复: 使用iPhone SDK确定设备(iPhone,iPod Touch)

我正在制作一款利用iPhone的对等蓝牙功能的游戏(可能还有iPod touch第二代)。但是,要阻止用户尝试在iPod 1st和iPhone 2G上播放多人游戏,我需要检查特定的设备型号。

I am making a game that utilizes the peer-to-peer bluetooth capabilities of the iPhone (and probably the iPod touch 2nd generation). However, to stop the users from trying to play a multiplayer on an iPod 1st gen and iPhone 2G I need to check for the specific device model.

[[UIDevice currentDevice] model]只会告诉我该设备是iPhone还是iPod touch。有没有办法检查特定的设备型号,如:iPhone 3GS,iPod touch 1st generation或其他什么。

[[UIDevice currentDevice] model] will only tell me if the device is an "iPhone" or an "iPod touch". Is there a way to check for the specific device model, like: "iPhone 3GS", "iPod touch 1st generation" or something.

编辑:

UIDevice有一个类别(我认为它是由Erica Sadun创建的,我不赞成它),它使用以下代码来获取具体信息设备模型。您可以在此处找到整个类别以及其他有用的内容: github/erica/uidevice -extension

There is a category to UIDevice (I think it's created by Erica Sadun, I don't take credit for it) that uses the following code to get the specific device model. You can find the whole category here along with other useful stuff: github/erica/uidevice-extension

#include <sys/types.h> #include <sys/sysctl.h> @implementation UIDevice (Hardware) /* Platforms iPhone1,1 -> iPhone 1G iPhone1,2 -> iPhone 3G iPod1,1 -> iPod touch 1G iPod2,1 -> iPod touch 2G */ - (NSString *) platform { size_t size; sysctlbyname("hw.machine", NULL, &size, NULL, 0); char *machine = malloc(size); sysctlbyname("hw.machine", machine, &size, NULL, 0); NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding]; free(machine); return platform; }

此作品和使用此功能的应用程序最近已在AppStore中获得批准。

This works and apps using this have been lately approved in the AppStore.

推荐答案

最完整的UIDevice(硬件)类别可能是 github/erica/uidevice-extension/ (作者Erica Sadun):

Most complete UIDevice (Hardware) category probably is github/erica/uidevice-extension/ (by Erica Sadun):

[[UIDevice currentDevice] platformType] // ex: UIDevice4GiPhone [[UIDevice currentDevice] platformString] // ex: @"iPhone 4G"

更多推荐

检测特定的iPhone / iPod touch型号

本文发布于:2023-08-01 15:44:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1269595.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:型号   iPhone   iPod   touch

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!