Created
December 9, 2013 23:45
-
-
Save erikvillegas1/7883183 to your computer and use it in GitHub Desktop.
Macros.h
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
#define strFormat(__FORMAT__,...) [NSString stringWithFormat:__FORMAT__,__VA_ARGS__] | |
#define showAlert(__TITLE__, __MSG__) [[[UIAlertView alloc] initWithTitle:__TITLE__ message:__MSG__ delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show] | |
#define strEquals(__STR__, __EQL1__) [__STR__ isEqualToString:__EQL1__] | |
#define strNotEquals(__STR__, __EQL1__) !strEquals(__STR__, __EQL1__) | |
#define strEqualsAny(__STR__, __EQL1__, __EQL2__) [__STR__ isEqualToString:__EQL1__] || [__STR__ isEqualToString:__EQL2__] | |
#define strEmpty(__STR__) (__STR__.length == 0) | |
#define fieldIsEmpty(__FIELD__) ([__FIELD__.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]].length == 0) | |
#define urlify(__STR__) [NSURL URLWithString:__STR__] | |
#define imagify(__STR__) [UIImage imageNamed:__STR__] | |
#define stringify(__DATA__) [[NSString alloc] initWithData:__DATA__ encoding:NSUTF8StringEncoding] | |
#define colorify(__R__,__G__,__B__,__A__) [UIColor colorWithRed:__R__/255.0f green:__G__/255.0f blue:__B__/255.0f alpha:__A__] | |
#define strAppend(__STR1__,__STR2__) [__STR1__ stringByAppendingString:__STR2__] | |
#define strAppendFormat(__STR__,__FORMAT__,...) [__STR__ stringByAppendingFormat:__FORMAT__,__VA_ARGS__] | |
#define MAIN_STORYBOARD [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] | |
#define instantiateVC(__VC__) [MAIN_STORYBOARD instantiateViewControllerWithIdentifier:__VC__] | |
#define pt(__X__,__Y__) CGPointMake(__X__,__Y__) | |
#define rect(__X__,__Y__,__W__,__H__) CGRectMake(__X__,__Y__,__W__,__H__) | |
#define size(__W__,__H__) CGSizeMake(__W__,__H__) | |
#define indexPathMake(__R__,__S__) [NSIndexPath indexPathForRow:__R__ inSection:__S__] | |
#define UIColorFromRGB(__HEX__, __A__) [UIColor \ | |
colorWithRed:((float)((__HEX__ & 0xFF0000) >> 16))/255.0 \ | |
green:((float)((__HEX__ & 0xFF00) >> 8))/255.0 \ | |
blue:((float)(__HEX__ & 0xFF))/255.0 alpha:__HEX__] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment