Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8713119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:15:55+00:00 2026-06-13T05:15:55+00:00

I intend to make a program that does the following: Create an NSArray populated

  • 0

I intend to make a program that does the following:

Create an NSArray populated with numbers from 1 to 100,000.
Loop over some code that deletes certain elements of the NSArray when certain conditions are met.
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 above post

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:15:56+00:00Added an answer on June 13, 2026 at 5:15 am

    You may want to look at NSMutableIndexSet. It is designed to efficiently store ranges of numbers.

    You can initialize it like this:

    NSMutableIndexSet *set = [[NSMutableIndexSet alloc]
        initWithIndexesInRange:NSMakeRange(1, 100000)];
    

    Then you can remove, for example, 123 from it like this:

    [set removeIndex:123];
    

    Or you can remove 400 through 409 like this:

    [set removeIndexesInRange:NSMakeRange(400, 10)];
    

    You can iterate through all of the remaining indexes in the set like this:

    [set enumerateIndexesUsingBlock:^(NSUInteger i, BOOL *stop) {
        NSLog(@"set still includes %lu", (unsigned long)i);
    }];
    

    or, more efficiently, like this:

    [set enumerateRangesUsingBlock:^(NSRange range, BOOL *stop) {
        NSLog(@"set still includes %lu indexes starting at %lu",
            (unsigned long)range.length, (unsigned long)range.location);
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I intend to make some software to be sold over internet. I've only created
I intend to make a web application that displays 3d environments that can be
I'm trying to make test-program that opens a website by pushing a button. I
I have a small app I've made that I intend to make available on
I am trying to create program that simply opens file on sdcard. I tried
I have this java swing application that I intend to sell over the internet.
I am trying to make a program that has 2 views. The first view
I intend to create a realtime counter. So one user can incremenet the counter
I intend to create asp.net pages using Visual Studio 2008. Preferably, the pages should
I intend to develop a J2ME application, that should be able to read words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.