Objective c 索引1超出界限时出错

Objective c 索引1超出界限时出错,objective-c,nsmutablearray,Objective C,Nsmutablearray,下面的代码我想发送matrix1Col和matrix2Col到乘法方法 但是索引1超出了界限是错误的 从内部UIButton代码 double kk[2][2] = {{1,2},{5,6}}; double t [2][1] = {1,2};` if (!matrix1Col) { matrix1Col = [NSMutableArray array]; } for (unsigned int i=0; i<2; i++) { matrix1Row = [NSMuta

下面的代码我想发送matrix1Col和matrix2Col到乘法方法

但是索引1超出了界限是错误的

从内部UIButton代码

double kk[2][2] = {{1,2},{5,6}};
double t [2][1] = {1,2};`

if (!matrix1Col) {
    matrix1Col = [NSMutableArray array];
}

for (unsigned int i=0; i<2; i++) {
    matrix1Row = [NSMutableArray new];
    for (unsigned int j=0 ; j<2; j++) {
        [matrix1Row addObject:@(kk[i][j])];
    }
    [matrix1Col addObject:matrix1Row];
}

if (!matrix2Col) {
    matrix2Col = [NSMutableArray array];
}

for (unsigned int i=0; i<2; i++) {
    matrix2Row = [NSMutableArray new];
    for (unsigned int j=0; j<1; j++) {
        [matrix2Row addObject:@(t[i][j])];
    }
    [matrix2Col addObject:matrix2Row];
}
NSMutableArray *resultMultiply = [self multiply:matrix1Col :matrix2Col];
我找不到出错的地方


感谢您的评论。

此行出现错误:

double value2 = [[[matrix2 objectAtIndex:k] objectAtIndex:j] doubleValue];

当错误发生时,k=0和j=1。matrix2的objectAtIndex:0只有一个对象,因此存在错误。

错误到底发生在哪里?谢谢。我已经将其更改为0。但我想知道为什么j=1,而我将其设置为小于matrix2RowCount,matrix2RowCount为1@SelfShearifter,不,我的调试器说matrix2RowCount是2。
2013-02-14 06:26:06.595 matrixMutableArray[21578:c07] *** Terminating app due to                     uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
double value2 = [[[matrix2 objectAtIndex:k] objectAtIndex:j] doubleValue];