You can do like this to detect iPhone X device according to dimension.
Swift
if UIDevice().userInterfaceIdiom == .phone && UIScreen.main.nativeBounds.height == 2436 {
//iPhone X
}
Objective - C
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone && UIScreen.mainScreen.nativeBounds.size.height == 2436) {
//iPhone X
}
But,
This is not sufficient way. What if Apple announced next iPhone with same dimension of iPhone X. so the best way is to use Hardware string to detect the device.
For newer device Hardware string is as below.
iPhone 8 - iPhone10,1 or iPhone 10,4
iPhone 8 Plus - iPhone10,2 or iPhone 10,5
iPhone X - iPhone10,3 or iPhone10,6