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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:41:02+00:00 2026-06-06T18:41:02+00:00

I want to use a variable-sized multi-dimensional array in my app to save data.

  • 0

I want to use a variable-sized multi-dimensional array in my app to save data. The data structure I want to use is as below, the first element in each row is followed by corresponding multiple values.

 array = {   {a, a_val1, a_val2, a_val3}.  
             {b, b_val1},  
             {c, c_val1, c_val2, c_val3, c_val4, c_val5}  
         }

Any idea how I can implement in objective-c?

  • 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-06T18:41:03+00:00Added an answer on June 6, 2026 at 6:41 pm

    Objective-C does not have a real 2 dimensional array type but you can implement it with the
    following codes..

    in your header file — yourheader.h

    #import <Foundation/Foundation.h>
    
    @interface yourheader : NSObject{
    
        NSMutableDictionary* DictionaryArrayType;
        NSMutableArray* MultiArrayType;
        NSArray* CaptionTitle;
        NSArray* ObjectValue;
    
    }
    
    @property (strong, nonatomic) NSMutableDictionary* DictionaryArrayType;
    
    @property (strong, nonatomic) NSArray* CaptionTitle;
    
    @property (strong, nonatomic) NSArray* ObjectValue;
    
    @property (strong, nonatomic) NSMutableArray* MultiArrayType;
    
    -(id) AddArrayObjects:(NSString*)_Name : (NSString*)_Surname :(NSString*)_Age;
    
    -(id) AddArrayDictionaryObject:(NSArray*)_ArrayObject : (NSArray*)_ArrayKey;
    
    -(id) AddMultiArrayType:(id)_ArrayObject;
    
    -(void) ShowMultiArrayType:(id)_ArrayObject;
    
    @end
    

    Now add to your objective-c file —- objective-c.m

    #import "yourheader.h"
    
    @implimentation yourheader
    
    @synthesize DictionaryArrayType;
    
    @synthesize CaptionTitle;
    
    @synthesize ObjectValue;
    
    @synthesize MultiArrayType;
    
    
    -(id)init {
    
        if(self = [super init]){
    
            NSString* const NAME = @"NAME";
            NSString* const SURNAME = @"SURNAME";
            NSString* const AGE = @"AGE";
            //Adding fixed content to CaptionTitle Array
            [self setCaptionTitle:[NSArray arrayWithObjects:NAME, SURNAME, AGE, nil]];
    
            //add values to ObjectValue array
            [self AddArrayObjects:@"Bob" :@"Obi" :@"200"];
    
            //add values to dictionary
            [self AddDictionaryArrayType:ObjectValue :CaptionTitle];
    
            //Add to the Multi dimensional array [][]
            [self AddMultiArrayType:DictionaryArrayType];  
    
            //add the second row values to ObjectValue array
            [self AddArrayObjects:@"Barack" :@"Obama" :@"50"]; 
    
            //add values to dictionary
            [self AddDictionaryArrayType:ObjectValue :CaptionTitle];
    
            //Add to the Multi dimensional array [][]
            [self AddMultiArrayType:DictionaryArrayType];  
    
            //display the 2d Array
            [self ShowMultiArrayType:MultiArrayType];
    
        }
    
        return self;
    }
    
    
    -(id)AddArrayObjects:(NSString *)_name :(NSString *)_surname :(NSString *)_age {
    
        //Set the Array Objects;
        [self setObjectValue:[NSArray arrayWithObjects:_name, _surname, _age, nil]];
    
        return self;
    
    }
    
    -(id)AddDictionaryArrayType:(NSArray *)_ArrayObject :(NSArray*)_ArrayKey {
    
        if(!DictionaryArrayType) {
            //initialize disctionary
            [self setDictionaryArrayType:[NSMutableDictionary dictionary]];
        }
        //add array obeject and Fixed Key decleared in CaptionTitle array
        DictionaryArrayType = [NSMutableDictionary dictionaryWithObjects:_ArrayObject forKeys:_ArrayKey];
        return self;
    }
    
    -(id) AddMultiArrayType:(id)_ArrayObject {
    
        if(!MultiArrayType) {
    
            [self setMultiArrayType:[NSMutableArray array]];
        }
    
        [MultiArrayType addObject:_ArrayObject]; 
    
        return self;
    }
    
    -(void)ShowMultiArrayType:_ArrayObject {
    
        for(id objects in _ArrayObject ) {
    
            for(id key in objects) {
                NSLog(@"%@ key = : object =  %@", key, [objects objectForKey:key]);
    
            }
        }
    }
    
    
    @end;
    

    To finish add this to your appdelegate.m file inside the app

      yourclassname* _yourclasspointer = [[yourclassname alloc] init];
    
     [_youclasspointer ShowMultiArrayType:[_yourclasspointer MultiArrayType]];
    

    You should see it in you console.

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

Sidebar

Related Questions

I want to use variable a from foo.c in main.c, and I write: foo.c
I am developing one web application. In that i want to use variable's value
I want to use a variable value in exec where i don't need to
I want to use a variable in a string. I have tried to do
I want to use a variable in a regex, like this: variables = ['variableA','variableB']
I want to use a global variable in inline assembly. asm( LDR R0,g_TsInitStackPointerAddress); Here
I want to use an environment variable in a command with recursive search. export
I am trying to use variable in different function, I want to set global
I want to use Perl's sprintf to zerofill a variable. sprintf(%08d, $var); But I
I want to use a variable for the legend key label in a ggplot

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.