populating an nsarray

Posted by MoKaM on Stack Overflow See other posts from Stack Overflow or by MoKaM
Published on 2012-10-22T22:58:07Z Indexed on 2012/10/22 23:00 UTC
Read the original article Hit count: 143

Filed under:
|
|
|

I intend to make a program that does the following:

  1. Create an NSArray populated with numbers from 1 to 100,000.
  2. Loop over some code that deletes certain elements of the NSArray when certain conditions are met.
  3. Store the resultant NSArray.

However the above steps will also be looped over many times and so I need a fast way of making this NSArray that has 100,000 number elements.

So what is the fastest way of doing it?

Is there an alternative to iteratively populating an Array using a for loop? Such as an NSArray method that could do this quickly for me?

Or perhaps I could make the NSArray with the 100,000 numbers by any means the first time. And then create every new NSArray (for step 1) by using method arraywithArray? (is it quicker way of doing it?)

Or perhaps you have something completely different in mind that will achieve what I want.

edit: Replace NSArray with NSMutableArray in this post.

© Stack Overflow or respective owner

Related posts about numbers

Related posts about nsarray