Objective c 在NSArray上调用objectAtIndex时发生NSRangeException

Objective c 在NSArray上调用objectAtIndex时发生NSRangeException,objective-c,nsarray,indexoutofboundsexception,Objective C,Nsarray,Indexoutofboundsexception,我得到了这个错误,我不明白为什么: *由于未捕获的异常“NSRangeException”而终止应用程序,原因:“-[\uuu”NSCFArray objectAtIndex]:索引(171053968)超出边界(226)” -(void)makeArrayOfGrade{ 布尔*已经添加; 对于(int a=0;a而言,问题可能是您在不存在的索引处请求allData的对象。 也就是说,表视图中的数据不适合allData我从这里取出所有数据:-(void)loadObjectFromPlistF

我得到了这个错误,我不明白为什么:

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

-(void)makeArrayOfGrade{
布尔*已经添加;

对于(int a=0;a而言,问题可能是您在不存在的索引处请求
allData
的对象。
也就是说,表视图中的数据不适合
allData

我从这里取出所有数据:-(void)loadObjectFromPlistFile{NSString*filePath=[[NSBundle mainBundle]pathForResource:@“plist”类型的“GDZ”;allData=[[NSMutableArray alloc]initwithContentsFile:filePath];我必须做什么?我可能还不明白..@AshVar,还要注意objectAtIndex需要一个整数,但您正在传递一个NSIndexPath。安娜·卡列尼娜,谢谢!它帮助了很多!现在它运行了,但我得到了白色屏幕。似乎我只需要重新加载tableView,但它没有帮助…有什么建议吗?
- (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");

        }
    }
}