Objective-C does not have a real 2-dimensional array type, but you can implement it using the following codes ..
in your header file --- yourheader.h
Now add in your objective-c file ---- objective-cm
#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 add this to the appdelegate.m file inside the application
yourclassname* _yourclasspointer = [[yourclassname alloc] init]; [_youclasspointer ShowMultiArrayType:[_yourclasspointer MultiArrayType]];
You should see it in the console.
source share