Skip to content

Instantly share code, notes, and snippets.

@tunitowen
Last active August 29, 2015 13:57
Show Gist options
  • Save tunitowen/9618413 to your computer and use it in GitHub Desktop.
Save tunitowen/9618413 to your computer and use it in GitHub Desktop.
NSNumber Macros
// magic macros
#define N(x) [NSNumber numberWithInt: x]
#define B(x) [NSNumber numberWithBool: x]
NSMutableArray *array = [[NSMutableArray alloc] init];
// long way
[array addObject:[NSNumber numberWithBool:YES]];
[array addObject:[NSNumber numberWithInt:1]];
// short way (using macro)
[array addObject:B(YES)];
[array addObject:N(1)];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment