I'm trying to detect if the current device is an iPhone X in Objective-C. I've looked at some other posts that do this in Swift and a proper method seems to be to compare the safe area insets with UIEdgeInsets.zero
. However, whenever I attempt to do this, I am getting nil
. I am running this on iOS 11 and the iPhone X simulator.
When I step through this method - I enter into the first clause, but still get a nil
returned.
- (BOOL)isiPhoneX
{
if (@available(iOS 11.0, *))
{
return UIEdgeInsetsEqualToEdgeInsets(self.safeAreaInsets, UIEdgeInsetsZero);
}
else
{
return nil;
}
}