Objective-C
Swift,
iOS,
iPhone,

iPhoneX と その他の識別のコード。備忘録ですね。

NSMutableDictionary *options;
struct utsname systemInfo;
uname(&systemInfo);
NSString* code = [NSString stringWithCString:systemInfo.machine
                                        encoding:NSUTF8StringEncoding];
BOOL sim_iPhoneX = ([code isEqualToString:@"x86_64"] && MAX([[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height) == 812);
if ([code isEqualToString:@"iPhone10,3"] || [code isEqualToString:@"iPhone10,6"] || sim_iPhoneX ) {
} else {
};
var size : Int = 0
sysctlbyname("hw.machine", nil, &size, nil, 0)
var machine = [CChar](repeating: 0, count: Int(size))
sysctlbyname("hw.machine", &machine, &size, nil, 0)
let code:String = String(cString:machine)
let sim_iPhoneX = (code == "x86_64" && max(UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height) == 812)
if (code == "iPhone10,3" || code == "iPhone10,6" && sim_iPhoneX) {
} else {
}

な、感じかなー。どっちも sys/utsname.h あたりはインポートする必要あるかもだけど。