Я читаю в CSV-файле, и теперь я анализирую строку и записываю элемент в 2D NSMutableArray.
Как я записываю элементы в 2D-массив, NSLog выводит ожидаемый элемент.*
Но когда я закончу анализ и запись всего файла в 2D-массив, NSLog показывает последний элемент в каждой строке для каждого столбца в этой строке.
- как если бы каждый элемент вряд был заменен.???почему, спасибо заранее ...
for (int i = 1; i < iM; i++) {//was a 1 to pass over the header
//get the row and break up into columns
nsmarrDummy = [NSMutableArray arrayWithArray:[[nsmarrRow objectAtIndex: i] componentsSeparatedByString: nsstrColParse]];
//write each item to the proper column in the 2d array at the given row
for (int j = 0; j < iN; j++) {//<<--
[[nsmarrData objectAtIndex:j] replaceObjectAtIndex:i-1 withObject: [nsmarrDummy objectAtIndex:j]];
NSLog(@"i:%d j:%d item:%@", i, j, [[nsmarrData objectAtIndex:j] objectAtIndex:i-1]);
}
}
//all the following are the same value, but doing the NSLog as it was writing was correct.
NSLog(@"FINAL: i:%d j:%d item:%@", 0, 4, [[nsmarrData objectAtIndex:4] objectAtIndex:0]);
NSLog(@"FINAL: i:%d j:%d item:%@", 0, 5, [[nsmarrData objectAtIndex:5] objectAtIndex:0]);
NSLog(@"FINAL: i:%d j:%d item:%@", 0, 6, [[nsmarrData objectAtIndex:6] objectAtIndex:0]);