I’m reading Apress - Beginning iPad Development for iPhone Developer Mastering the iPad SDK and in one chapter i read about device checking and author write:
“Although you may be temped to simply check the user’s device type or operating system version, with Apple constantly releasing new devices and iOS versions, that’s not the way to go. A better approach is to test for the availability of exclusive iPad classes using NSClassFromString. If you pass an iPad-only class name, such as UISplitViewController to NSClassString and a valid object is returnet, you’ll know user’s device is an iPad..”
I don’t understand, why simply check device type for example by:
NSString *device = [[UIDevice currentDevice] model];
if ([device rangeOfString:@"iPad"].location != NSNotFound ) {
isIPad = true;
}
else isIPad = false;
Is worse than checking ipad classes?
The way that Apple checks in their own examples and when you start a new universal application is like so:
And the reason why using model is probably bad is because you’re just using a string comparison. While I doubt they will change it, you never know when they might decide to change the string returned by using
[[UIDevice currentDevice] model]to model number or something else.