I am unable to get clear idea about the following method:
- (BOOL) isPad {
#ifdef UI_USER_INTERFACE_IDIOM
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#else
return NO;
#endif
}
Actually for iPad applications this method is used but I don’t understand that this method actually does, so if anyone could explain it in detail it would be very helpful for me.
Thanks in advance.
The method simply checks if the
UI_USER_INTERFACE_IDIOMmacro has been defined.If it is available, it checks to see whether the macro is equal to
UIUserInterfaceIdiomPad. If the comparison is true, it returns YES, otherwise if will return NO.If the macro has not been defined, it means you are running iOS < 3.2 so it is definitely not an iPad.
For documentation, see http://developer.apple.com/library/ios/documentation/uikit/reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/macro/UI_USER_INTERFACE_IDIOM