Skip to content

Instantly share code, notes, and snippets.

@wess
Created January 15, 2013 16:19
Show Gist options
  • Save wess/4539807 to your computer and use it in GitHub Desktop.
Save wess/4539807 to your computer and use it in GitHub Desktop.
My Macros
//
// WCMacros.h
// WessCioe
//
// Created by Wess Cope on 10/9/12.
// Copyright (c) 2012 WessCope. All rights reserved.
//
#ifndef __WC__MACROS__
#define __WC__MACROS__
#define AND &&
#define OR ||
#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
#define APP_BUNDLE_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#define APP_EXECUTABLE [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"]
#define APP_NAME [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]
#define SYSTEM_NAME [[UIDevice currentDevice] systemName]
#define SYSTEM_VERSION [[UIDevice currentDevice] systemVersion]
#define DEVICE_TYPE [UIDevice currentDevice].model
#define RED [UIColor redColor]
#define WHITE [UIColor whiteColor]
#define BLACK [UIColor blackColor]
#define BLUE [UIColor blueColor]
#define GREEN [UIColor greenColor]
#define YELLOW [UIColor yellowColor]
#define MAGENTA [UIColor magentaColor]
#define GRAY [UIColor grayColor]
#define LIGHTGRAY [UIColor lightGrayColor]
#define CLEAR [UIColor clearColor]
#define HEX_COLOR(hex) [UIColor fromHexString:hex]
#define PATH_FOR_RESOURCE(filename, type) [[NSBundle mainBundle] pathForResource:filename ofType:type]
#define READ_FILE(filename, type) [[NSString alloc] initWithContentsOfFile:PATH_FOR_RESOURCE(filename, type) encoding:NSUTF8StringEncoding error:nil]
#define SCREEN_BOUNDS [[UIScreen mainScreen] bounds]
#define IS_IPAD ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)? YES : NO)
#define STATUS_BAR_ORIENTATION [[UIApplication sharedApplication] statusBarOrientation]
#define STATUS_BAR_IS_LANDSCAPE (UIDeviceOrientationIsLandscape(STATUS_BAR_ORIENTATION))
#define STATUS_BAR_IS_PORTRAIT (UIDeviceOrientationIsPortrait(STATUS_BAR_ORIENTATION))
#define FLEX_BOTTOM UIViewAutoresizingFlexibleBottomMargin
#define FLEX_TOP UIViewAutoresizingFlexibleTopMargin
#define FLEX_LEFT UIViewAutoresizingFlexibleLeftMargin
#define FLEX_RIGHT UIViewAutoresizingFlexibleRightMargin
#define FLEX_WIDTH UIViewAutoresizingFlexibleWidth
#define FLEX_HEIGHT UIViewAutoresizingFlexibleHeight
#define FLEX_NONE UIViewAutoresizingNone
#define FLEX_ALL FLEX_BOTTOM | FLEX_TOP | FLEX_LEFT | FLEX_RIGHT | FLEX_WIDTH | FLEX_HEIGHT
#define FLEX_SIZE FLEX_WIDTH | FLEX_HEIGHT
#define FLEX_ORIGIN FLEX_BOTTOM | FLEX_TOP | FLEX_LEFT | FLEX_RIGHT
#define GLOBAL_QUEUE dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
#define MAIN_QUEUE dispatch_get_main_queue()
// User Defaults
#define GET_USER_DEFAULT(key) [[NSUserDefaults standardUserDefaults] valueForKey:key]
#define GET_USER_DEFAULT_INT(key) [[NSUserDefaults standardUserDefaults] integerForKey:key]
#define GET_USER_OBJECT(key) [[NSUserDefaults standardUserDefaults] objectForKey:key]
#define SET_USER_DEFAULT(key, val) [[NSUserDefaults standardUserDefaults] setValue:val forKey:key]
#define SET_USER_DEFAULT_OBJECT(key, obj) [[NSUserDefaults standardUserDefaults] setObject:obj forKey:key]
#define SET_USER_DEFAULT_INT(key, intgr) [[NSUserDefaults standardUserDefaults] setInteger:intgr forKey:key]
#define DELETE_USER_DEFAULT(key) [[NSUserDefaults standardUserDefaults] removeObjectForKey:key]
#define SYNC_USER_DEFAULTS [[NSUserDefaults standardUserDefaults] synchronize]
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment