Last active
August 29, 2015 13:57
-
-
Save tunitowen/9618413 to your computer and use it in GitHub Desktop.
NSNumber Macros
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
// 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