Is there a nicer way to fill an array with numbers than what I use? It's crazy how much I got to write just to fill an array with numbers so they can be used for a calculation in a loop. This is easier in other C based languages like PHP, As3, or Java.
NSArray *myArray = [NSArray arrayWithObjects:
[NSNumber numberWithInt:1000],[NSNumber numberWithInt:237], [NSNumber numberWithInt:2673], nil];
int total = 0;
for(int i = 0; i < [myArray count]; i += 1 ){
total += [[myArray objectAtIndex: i]intValue];
NSLog(@"%i", total);
}
Hopefully there is a shorter way... I just want to fill an array with ints... cant be that hard
NSNumberobjects, they can be stored in collections and automatically encoded/decoded to files/network streams, etc. For other things you may want good old C ints in a C array, for super-fast lookup and usage (for example a frequency table in an audio processing function). In Objective-C you can choose which is the most appropriate, it supports both.