Personally, I find myself using arrays of integers so often that I had to streamline the process a bit. For instance:
NSArray myList=klist(4,2,3,2,3);
is equivalent to something like:
NSArray myList = [NSArray arrayWithObjects:
[NSNumber numberWithInt:2],
[NSNumber numberWithInt:3],
[NSNumber numberWithInt:2],
[NSNumber numberWithInt:3],nil];
Here are the functions that I use:
#define kInt(x) [NSNumber numberWithInt:x]
#define kArray(...) [NSMutableArray arrayWithObjects: __VA_ARGS__,nil]
#define klist(...) [arrays iList:__VA_ARGS__]
#define k1ist(x) [arrays iList:1,x]
#define krange(x) [arrays range:x]
#define kAppend(...) [arrays append_arrays:__VA_ARGS__,nil]
@interface arrays : NSObject
{}
+(NSMutableArray *) range:(int) i;
+(NSMutableArray *) iList:(int) n, ...;
@end
@implementation arrays
+(NSMutableArray *) range:(int) i{
NSMutableArray *myRange = [NSMutableArray array];
for (int I=0;I<i;I++)
{
[myRange addObject:kInt(I)];
}
return myRange;
}
+(NSMutableArray *) iList:(int) n, ...{
int ii;
NSMutableArray *myRange = [NSMutableArray array];
va_list myArgs;
va_start(myArgs,n);
for (int i=0;i<n;i++){
ii = va_arg(myArgs,int);
[myRange addObject: kInt(ii)];
}
return myRange;
}
@end
int myArrayInteger[30];