Python can make a list with continuous numbers like this:
numbers=range(1,10); // >> [1,2,3,4,5,6,7,8,9]
How to implement this in Objective-c?
Reading your statement "
Just need an array with continuous numbers,I do not want to init it with a loop" lets me ask: what is more important for you: to have an array
or to have "something" that represents a continuous range of (natural) numbers. Have a look at NSIndexSet
It may come close to what you want. You initialize it with
[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1,9)];
Iterating over this set is as simple as iterating over an array and does not need NSNumbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With