Skip to content

Instantly share code, notes, and snippets.

@fahied
Created June 22, 2015 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fahied/27da57d40a5805fe4535 to your computer and use it in GitHub Desktop.
Save fahied/27da57d40a5805fe4535 to your computer and use it in GitHub Desktop.
iOS Useful Macros
// Constants
#define APP_VERSION [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]
#define APP_NAME [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]
#define APP_DELEGATE [[UIApplication sharedApplication] delegate]
#define USER_DEFAULTS [NSUserDefaults standardUserDefaults]
#define APPLICATION [UIApplication sharedApplication]
#define BUNDLE [NSBundle mainBundle]
#define MAIN_SCREEN [UIScreen mainScreen]
#define DOCUMENTS_DIR [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]
#define IS_PAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
// Props
#define ScreenWidth [MAIN_SCREEN bounds].size.width
#define ScreenHeight [MAIN_SCREEN bounds].size.height
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment