Skip to content

Instantly share code, notes, and snippets.

@djones
Created August 14, 2010 03:33
Show Gist options
  • Save djones/523915 to your computer and use it in GitHub Desktop.
Save djones/523915 to your computer and use it in GitHub Desktop.
A nicer way to do runtime conditional coding for iPad and iPhone/iPod Touch
@interface UIDevice (Utilities) {}
+ (BOOL)iPad;
@end
#import "UIDevice+Utilities.h"
@implementation UIDevice (Utilities)
+ (BOOL)iPad {
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
}
@end
#import "YourClass.h"
@implementation YourClass
- (void)doSomething {
if ([UIDevice iPad]) {
// code for iPad
} else {
// code for iPhone or iPod Touch
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment