---
title: "(iphone/ipad)一个简单的用代码判断当前设备的方法"
author: "sabolasi"
date: "2011-12-05T00:52:00Z"
tags: []
slug: "iphone-ipad"
draft: false
lastmod: "2011-12-07T17:19:10Z"
id: 1296206
url: "https://sabolasi.iteye.com/blog/1296206"
---

直接NSLog(@"current\_device:%@",\[UIDevice currentDevice].model);

即可看出它输出的是当前设备，所以根据这个字符串可简单的判断当前是什么设备，进而实现一些要求不严格的操作，例如 打电话，分辨率资源配置等

```
NSString *device = [[UIDevice currentDevice].model substringToIndex:4];
if ([device isEqualToString:@"iPho"]){
 // This is iPhone.
}else if ([device isEqualToString:@"iPad"]){
 // This is iPad.
}else if([device isEqualToString:@"iPod"]){
 // This is iPod.
}
```

另外备份一个文章：

iOS 打电话的三种方式：对审核有些提示，可以看看

http://diandianyangsamllplace.diandian.com/post/2011-08-03/3497785