Created
July 30, 2013 08:05
-
-
Save burczyk/6111139 to your computer and use it in GitHub Desktop.
Some useful iOS development macros
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
#ifndef Constants_h | |
#define Constants_h | |
#pragma mark some useful macros | |
#define DEFAULTS [NSUserDefaults standardUserDefaults] | |
#define DEFAULTS_SET(key, value) [[NSUserDefaults standardUserDefaults] setObject:value forKey:key]; [[NSUserDefaults standardUserDefaults] synchronize]; | |
#define INSTANTIATE(viewController) [[UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:viewController]; | |
#define INSTANTIATE_VIEW(name) [[[NSBundle mainBundle] loadNibNamed:name owner:self options:nil] objectAtIndex:0]; | |
#define NETWORK_ON [UIApplication sharedApplication].networkActivityIndicatorVisible = YES | |
#define NETWORK_OFF [UIApplication sharedApplication].networkActivityIndicatorVisible = NO | |
#define IS_LANDSCAPE ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight || UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) | |
#define SCREEN_HEIGHT (IS_LANDSCAPE ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height) | |
#define SCREEN_WIDTH (IS_LANDSCAPE ? [[UIScreen mainScreen] bounds].size.height : [[UIScreen mainScreen] bounds].size.width) | |
#define STATUS_BAR_HEIGHT 20 | |
#define TRACKER [[GAI sharedInstance] defaultTracker] | |
#define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI) | |
#define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI)) | |
#define MUST_OVERRIDE [NSException raise:NSInternalInconsistencyException format:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)] | |
#define FILE_NAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) | |
#define FRAME_STR(frame) [NSString stringWithFormat:@"(%.0f, %.0f; %.0f %.0f)", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height] | |
#define DEBUG_STRING(str) [NSString stringWithFormat:@"%s %d %s\n%@", __FILE__, __LINE__, __PRETTY_FUNCTION__, str] | |
#define IPAD UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad | |
#endif | |
extern int ddLogLevel; |
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 "Constants.h" | |
#ifdef DEBUG | |
int ddLogLevel = LOG_LEVEL_VERBOSE; | |
#else | |
int ddLogLevel = LOG_LEVEL_WARN; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment