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 8805257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:49:08+00:00 2026-06-14T01:49:08+00:00

How do you fill a NSMutableArray with a set capacity for later use? Basically

  • 0

How do you fill a NSMutableArray with a set capacity for later use?

Basically I want to set up a NSMutableArray to act as a map for my game objects, so I have this line…

gameObjects = [[NSMutableArray alloc] initWithCapacity:mapWidth*mapHeight];

Which I had hoped would create and fill my MutableArray so I can get then access it with this kind of index…

int ii = (cellY*mapWidth)+cellX;

NSDictionary *currentObject = [gameObjects objectAtIndex:ii];

But I just learned initWithCapacity doesn’t fill the array, so should I create blank objects to fill it with, or is there a Null that I can fill it with? Also would I do that with 2 for loops or is there an instruction something like “initWith:myObject” ?

I want to be able to check at a certain index within the array to see if there’s an object there or not, so I need to be able to acces that index point, and I can only do that if there’s something there or I get an out of bounds error.

I’ll be using this NSMutableArray pretty much as a grid of objects, it’s a 1 dimensional array organised as a 2 dimensional array, so I need to be able to fill it with mapWidth*mapHeight of something, and then calculate the index and do a check on that index within the array.

I’ve looked on here and googled but couldn’t find anything like what I’m asking.

Thanks for any advice.

  • 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-14T01:49:10+00:00Added an answer on June 14, 2026 at 1:49 am

    I think what you are looking for is [NSNull null]. It is exactly what you want- a placeholder value.

    You can find more information on the topic in this question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a NSMutableArray filled with NSMutableArray's. I would like to fill my table
I fetch records from core data and fill NSMutableArray with them,now i want to
in my project I use a NSmutablearray that I fill with UIImageView in .m
I have this situation array = [[NSMutableArray alloc] initWithCapacity:4]; //in viewDidLoad if (index ==
I have an instance variable called users defined as NSMutableArray . I use that
I want to make a NSMutableArray and fill it up with rectangles created with,
I have a UIViewController that contains a UITableView. I'm trying to fill this table
I have a custom object and NSMutableArray as instance member. I fill the array
I have a problem with a NSMutableArray. I want to create a loop that
Is it possible to fill jQuery variable by PHP??? I mean something like this:

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.