What are all the possible values returned by [[UIDevice currentDevice] model];
? It isn't documented.

- 39,458
- 17
- 135
- 184

- 5,213
- 6
- 35
- 44
4 Answers
The possible vales are iPod touch
, iPhone
, iPhone Simulator
, iPad
, iPad Simulator
If you want to know which hardware iOS
is ruining on like iPhone3
, iPhone4
, iPhone5
etc below is the code for that
NOTE: The below code may not contain all device's string, I'm with other guys are maintaining the same code on GitHub so please take the latest code from there
Objective-C : GitHub/DeviceUtil
Swift : GitHub/DeviceGuru
#include <sys/types.h>
#include <sys/sysctl.h>
- (NSString*)hardwareDescription {
NSString *hardware = [self hardwareString];
if ([hardware isEqualToString:@"iPhone1,1"]) return @"iPhone 2G";
if ([hardware isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([hardware isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
if ([hardware isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";
if ([hardware isEqualToString:@"iPhone5,1"]) return @"iPhone 5";
if ([hardware isEqualToString:@"iPod1,1"]) return @"iPodTouch 1G";
if ([hardware isEqualToString:@"iPod2,1"]) return @"iPodTouch 2G";
if ([hardware isEqualToString:@"iPad1,1"]) return @"iPad";
if ([hardware isEqualToString:@"iPad2,6"]) return @"iPad Mini";
if ([hardware isEqualToString:@"iPad4,1"]) return @"iPad Air WIFI";
//there are lots of other strings too, checkout the github repo
//link is given at the top of this answer
if ([hardware isEqualToString:@"i386"]) return @"Simulator";
if ([hardware isEqualToString:@"x86_64"]) return @"Simulator";
return nil;
}
- (NSString*)hardwareString {
size_t size = 100;
char *hw_machine = malloc(size);
int name[] = {CTL_HW,HW_MACHINE};
sysctl(name, 2, hw_machine, &size, NULL, 0);
NSString *hardware = [NSString stringWithUTF8String:hw_machine];
free(hw_machine);
return hardware;
}

- 39,458
- 17
- 135
- 184
-
14I'm curious why was this accepted. It doesn't answer the question at all. – rmaddy Jan 19 '13 at 06:15
-
It looks to me like it did, but in a roundabout way. – Tomas McGuinness Jan 19 '13 at 08:12
-
@Inder Kumar Rathore, in iOS 6.1 this func is not work at perfectly. In 1 case from 3, then can return a other value – CReaTuS Feb 21 '13 at 04:50
-
@CReaTuS Have you tried open project of mine here https://github.com/rathore619/UIDevice-Hardware – Inder Kumar Rathore Feb 21 '13 at 05:16
-
@InderKumarRathore. Thanks, in this link, func **hardwareString** is changed. Will try =) – CReaTuS Feb 21 '13 at 05:22
-
@InderKumarRathore It works, please update your answer with new function =) – CReaTuS Feb 21 '13 at 23:05
-
@CReaTuS I have updated my answer. And please share new string if you found any for new hardware so that the above project remains updated. :) – Inder Kumar Rathore Feb 22 '13 at 03:24
-
@InderKumarRathore hardware was iPad3,1, but function will return as nil string, what so interest, in 1 case from 3. And sure, if i will found a new values, i will let u know – CReaTuS Feb 22 '13 at 06:10
-
iPhone5c and iPhone5s returns are iPhone6,1 and iPhone6,2 – CReaTuS Oct 16 '13 at 21:44
-
@CReaTuS somebody has pushed the code in git for iPhone 5c and iPhone 5s – Inder Kumar Rathore Oct 17 '13 at 04:39
-
It would be really nice to be able to return "isSimulator" as well as the simulated device model. – Alex Zavatone Feb 14 '14 at 14:08
-
Alex I have posted open source project please help youself as well as us too – Inder Kumar Rathore Feb 14 '14 at 14:18
-
for iphone 6 and iphone 6 plus code is: iPhone7,2 and iPhone7,1 – CReaTuS Sep 23 '14 at 06:28
-
Thanks @CReaTuS I will add this to git hub project. – Inder Kumar Rathore Sep 23 '14 at 07:19
-
First of all, thank you for the amazing answer. And my question is will apple reject my app if I use this code ? – Thilina Chamath Hewagama Oct 23 '14 at 03:09
-
@ThilinaCháminHewagama Whatever methods I have used in this are well documented and hence apple won't have any issues with it. You can use it without any fear. – Inder Kumar Rathore Oct 24 '14 at 08:15
-
This is an excellent answer to a completely unrelated question. What the op asked was which values are returned specifically from UIDevice.currentDevice().model. What has been answered and discussed here is a completely unrelated way of getting information about the current device (which is great, but in no way an answer to the question). – BobDickinson Dec 06 '14 at 20:19
-
oops for iphone 6 and 6 plus is there a different model number for CDMA devices ? – thndrkiss Feb 05 '15 at 22:04
I just did a test on iPod Touch, iPhone, Phone Retina, iPhone 5, iPad, iPad Retina and iPad Mini. So this is my conclusion:
iPod touch
iPhone
iPad
On simulators - this could be useful if you're a developer working on features that sometimes do not work at all on simulators - you'll get these values:
iPhone Simulator
iPad Simulator

- 32,953
- 42
- 145
- 236

- 658
- 1
- 6
- 12
-
Ah, the actual answer to the posted question! Thanks. I was specifically wondering if the iPad Mini would be indicated and didn't have one handy (and it's not supported in the XCode simulator), and this answered that. – BobDickinson Dec 06 '14 at 20:21
-
I believe the best answer to explain(something which wasn't written here) Is to say that the value itself is a String value. and the possible answers are string e.g: "iPhone","iPad" and etc..

- 55
- 8
None of these answers are extendable for new model numbers. Here is an enumeration:
public enum DeviceType {
case iPad(String?)
case iPhone(String?)
case simulator(String?)
case appleTV(String?)
case unknown
}
And Extension I wrote that I think is a little cleaner and a little more extendable for when new model number come out.
extension UIDevice {
public static func getDevice() -> DeviceType {
var info = utsname()
uname(&info)
let machineMirror = Mirror(reflecting: info.machine)
let code = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8, value != 0 else {
return identifier
}
return identifier + String(UnicodeScalar(UInt8(value)))
}
if code.lowercased().range(of: "ipad") != nil {
if let range = code.lowercased().range(of: "ipad") {
var mutate = code
mutate.removeSubrange(range)
return .iPad(mutate)
}else{
return .iPad(nil)
}
}else if code.lowercased().range(of: "iphone") != nil {
if let range = code.lowercased().range(of: "iphone") {
var mutate = code
mutate.removeSubrange(range)
return .iPhone(mutate)
}else{
return .iPhone(nil)
}
}else if code.lowercased().range(of: "i386") != nil || code.lowercased().range(of: "x86_64") != nil{
return .simulator(code)
}else if code.lowercased().range(of: "appletv") != nil {
if let range = code.lowercased().range(of: "appletv") {
var mutate = code
mutate.removeSubrange(range)
return .appleTV(mutate)
}else{
return .appleTV(nil)
}
}else{
return .unknown
}
}
}

- 5,244
- 1
- 39
- 54