Skip to content

Instantly share code, notes, and snippets.

@garaemon
Created March 29, 2012 01:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garaemon/2232015 to your computer and use it in GitHub Desktop.
Save garaemon/2232015 to your computer and use it in GitHub Desktop.
UtilityMacros.h
#define DICT(...) ([NSDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil])
#define MDICT(...) ([NSMutableDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil])
#define FORMAT(...) ([NSString stringWithFormat:__VA_ARGS__])
#define ARRAY(...) ([[NSArray alloc] initWithObjects:__VA_ARGS__, nil])
#define MARRAY(...) ([[NSMutableArray alloc] initWithObjects:__VA_ARGS__, nil])
#define ASSOC(D, K) ([D objectForKey:K])
#define PREDICATE(F, ...) ([NSPredicate predicateWithFormat:F, __VA_ARGS__])
#define LOCALIZED_STRING(S) (NSLocalizedString(S, S))
#define IS_VALID_STRING(s) (s && s != NULL && ![s isEqual:[NSNull null]])
#define CG_RECT_MAKE_SHORT(N) (CGRectMake(N##_X, N##_Y, N##_WIDTH, N##_HEIGHT))
#define UI_FONT_SHORT(N) ([UIFont fontWithName:N size:N##_SIZE])
#define RGB(R,G,B) ([UIColor colorWithRed:R green:G blue:B alpha:1.0])
#define RGBA(R,G,B,A) ([UIColor colorWithRed:R green:G blue:B alpha:A])
#define RGB255(R,G,B) ([UIColor colorWithRed:R/255.0 \
green:G/255.0 \
blue:B/255.0 \
alpha:1.0])
#define RGBA255(R,G,B, A) ([UIColor colorWithRed:R/255.0 \
green:G/255.0 \
blue:B/255.0 \
alpha:A])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment