Skip to content

Instantly share code, notes, and snippets.

@toshi0383
Last active August 29, 2015 14:11
Show Gist options
  • Save toshi0383/c16cbb6d1d6d1387ccae to your computer and use it in GitHub Desktop.
Save toshi0383/c16cbb6d1d6d1387ccae to your computer and use it in GitHub Desktop.
NSArray にdefineマクロの数値を突っ込むと。。 ref: http://qiita.com/toshi0383/items/c15581f18c49714714c5
#define ZERO 0
#define ONE 1
#define A "a"
NSLog(@"ONE = %d", ONE);
NSArray *array = [NSArray arrayWithObjects:ZERO, ONE, A, nil];
NSLog(@"array.count = %d", array.count);
NSLog(@"array = %@", array);
array = [NSArray arrayWithObjects:@"0", @"1", nil];
NSLog(@"array.count = %d", array.count);
NSLog(@"array = %@", array);
for (int i = 0; i < array.count; i++) {
id a = array[i];
NSLog(@"class of a is: %@", [a class]);
}
2014-12-10 18:22:43.297 TEST[76897:3889959] ONE = 1
2014-12-10 18:22:43.297 TEST[76897:3889959] array.count = 0
2014-12-10 18:22:43.298 TEST[76897:3889959] array = (
)
2014-12-10 18:22:43.298 TEST[76897:3889959] array.count = 2
2014-12-10 18:22:43.298 TEST[76897:3889959] array = (
0,
1
)
2014-12-10 18:22:43.298 TEST[76897:3889959] class of a is: __NSCFConstantString
2014-12-10 18:22:43.298 TEST[76897:3889959] class of a is: __NSCFConstantString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment