0

我收到此错误,但我不明白为什么:

*由于未捕获的异常“NSRangeException”而终止应用程序,原因:“-[__ NSCFArray objectAtIndex]:索引 (171053968) 越界 (226)”

- (void)makeArrayOfGrade{

    BOOL *alreadyAdded;
    for (int a = 0; a <= [allData count]-1; a++) {
        NSIndexPath *path = [NSIndexPath indexPathForRow:a inSection:0];
        NSDictionary *dict = [allData objectAtIndex:path];

        if ([[dict objectForKey:@"grade"] isEqualToString: @"5 класс"]) {

            /*     for (int i = 0; i <= [allData count]; i++){
             NSIndexPath *inPath = [NSIndexPath indexPathForRow:i inSection:0];
             NSDictionary *inDict = [allData objectAtIndex:path];
             if ([dict objectForKey:@"subject"]==[inDict objectForKey:@"subject"]) {
             added=YES;
             }
             }
             }
             if (added==NO) { */
            [dataForEachGrade addObject:dict];
            NSLog(@"added");

        }
    }
}
4

1 回答 1

1

问题可能是您请求的对象allData位于不存在的索引处。即,您的表格视图中的数据不适合allData.

于 2013-02-06T17:18:38.570 回答