Device detection in iOS

2012-09-28 Updated 2025-12-31 · dc272e6

This is just a quick tip on how to determine what device the user is running, this can be useful if you are writing an app for both iPhone and iPad and want to implement a feature in one device but not the other: Code snippet:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
//executed if phone
}
else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
//executed if ipad
}
else{
//Apple invented a new iDevice
}

Another thing we can check for is the version of iOS the user is running as well as the system name,here I simply used NSLog to output the results:

NSLog(@"%@",[[UIDevice currentDevice] systemVersion]);
NSLog(@"%@",[[UIDevice currentDevice] systemName]);

UIDevice has many other methods and properties regarding the users device, you can read through them in Apple's documentation here.


Originally posted on Blogspot