This is a fairly simple python built-in, for example: x = range(0,100) How can I accomplish the same feat using objective-c methods? Of course, there is something better than NSMutableArray and for-loop:
NSMutableArray *x = [NSMutableArray arrayWithCapacity:100]; for(int n=0; n<100; n++) { [x addObject:[NSNumber numberWithInt:n]]; }
Yes, I know that doing this most likely is not what I actually want to do (for example: xrange in python), but please, humor is my curiosity. =)
Clarification: I would like NSArray to contain a sequence of NSNumbers, so that the array could be further processed, for example, by shuffling elements or sorting by external metric.
source share