Created
August 14, 2010 03:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface UIDevice (Utilities) {} | |
+ (BOOL)iPad; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UIDevice+Utilities.h" | |
@implementation UIDevice (Utilities) | |
+ (BOOL)iPad { | |
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad); | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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