下面的代码我想发送matrix1Col和matrix2Col乘法。索引1超出范围时出错
但它与索引1超出边界的错误。
从
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];
在ViewController.m另一种方法里面的UIButton代码:
这是错误代码:
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:
我找不到它在那里的错误。
感谢您的评论。
错误发生在哪里? – Sebastian 2013-02-14 00:04:15