I am new at iOS Dev. I want to save two different arrays (array1
& array2
) in 2 dimensional array. I know how to save data directly in two dimensional array but can't by save two different arrays in one.
NSString* path = [[NSBundle mainBundle] pathForResource:@"Aasvogel" ofType:@"txt"];
NSString* content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];
NSArray* foo = [content componentsSeparatedByString: @","];
NSMutableArray *array1 = @[], *array2 = @[];
for ( int i = 0; i < [foo count]; i++ )
{
NSString* day = foo[i];
if ( i % 2 == 0 ) { [array1 addObject:day];}
else { [array2 addObject:day];}
}
// and here i have populated two arrays (array1 and array2)
// Now i want to save these arraya in below two dimensional array (dataArray) atIndex:0 and at Index:1
NSMutableArray *dataArray = [[NSMutableArray alloc] initWithCapacity: 2];
[dataArray addObject:[NSMutableArray arrayWithObjects:@"e",
@"el",
@"ale",
@"vela",
@"gavel",nil] atIndex:0];
[dataArray addObject:[NSMutableArray arrayWithObjects:@"Represents 50 in Roman numeral",
@"Building Wing",
@"Pub Brew",
@"Thin Parchment or membranes",
@"chairperson's hammer",nil] atIndex:1];