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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:18:11+00:00 2026-05-28T05:18:11+00:00

For C I would init an array like this: NSInteger x[3][10]; That works. Below

  • 0

For C I would init an array like this:

NSInteger x[3][10]; That works.

Below I have a one dim array that works. Would like to move all of this to a 2 dim array, How do I init it? So in other words take the code below and make it work with 2 dimensions.

NSMutableArray *SRData;

SRData = [[NSMutableArray alloc] init];


NSMutableDictionary *SRRow;

SRRow = [[NSMutableDictionary alloc] init];

[SRRow setObject:@"Read" forKey:@"Descr"];
[SRRow setObject:@"Read2.png" forKey:@"Img"];

[SRRow setObject:@"Read the codes" forKey:@"Det"];

[SRData addObject:SRRow] ;   

[SRRow release];
  • 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-05-28T05:18:11+00:00Added an answer on May 28, 2026 at 5:18 am

    In Objective-C, you just have to have an array of arrays to get the second dimension. To my knowledge, there is no shorthand, so you’re stuck doing something like the following:

    NSMutableArray *firstDimension = [[NSMutableArray alloc] init];
    for (int i = 0; i < rows; i++)
    {
        NSMutableArray *secondDimension = [[NSMutableArray alloc] init];
        [firstDimension addObject:secondDimension];
    }
    

    So all you would do is add your other objects (in your case, the NSMutableDictionarys) to the secondDimension array. Usage would be like:

    [[firstDimension objectAtIndex:0] objectAtIndex:0];
    

    Edit

    Full code example:

    NSMutableArray *SRData = [[NSMutableArray alloc] init]; //first dimension
    NSMutableArray *SRRow = [[NSMutableArray alloc] init]; //second dimension
    [SRData addObject:SRRow]; //add row to data
    [SRRow release];
    
    NSMutableDictionary *SRField = [[NSMutableDictionary alloc] init]; //an element of the second dimension
    [SRField setObject:@"Read" forKey:@"Descr"];
    //Set the rest of your objects
    
    [SRRow addObject:SRField]; //Add field to second dimension
    [SRField release];
    

    Now, to get at that “field” you would use code such as the following:

    [[SRData objectAtIndex:0] objectAtIndex:0]; //Get the first element in the first array (the second dimension)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array that gets created from JSON. The array looks like this:
I have a method that starts like this: public static UnboundTag ResolveTag(Type bindingType, string
I have something like this on my core data class to fetch all data
I have an array declared in my header file like this: int snapshot[kSnapshotSize]; which
I have a function on a background thread that looks like this: NSMutableArray *descriptions
I have a C library that has types like this: typedef struct { //
How would you accomplish this? mkdir newbuild cd newbuild git init git remote add
I have an images folder with a png in it. I would like to
I have a directory with 500,000 files in it. I would like to access
My Case: I have original Page Control app from Apple. I would like to

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.