LoginSignup
2
2

More than 5 years have passed since last update.

iPhoneXかどうか

Last updated at Posted at 2017-10-20

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 あたりはインポートする必要あるかもだけど。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2