kwigbo

Adventures in iOS!

1 note

Check if Current Device is iPad

This is a simple method I use in all my apps to easily tell if the current device is iPad. I add the import for this class to the Prefix.pch file so I can easily check what device I am on without having to import.

//Device.h
@interface Device : NSObject 
{
}
+ (BOOL) isPad;
@end
 
//Device.m
#import "Device.h"
 
@implementation Device
+ (BOOL) isPad
{
#ifdef UI_USER_INTERFACE_IDIOM
	return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
#endif
	return NO;
}
@end

Filed under snippet

  1. kwigbo posted this