所以我在尝试访问数组中的 SECOND 项后出现此错误。当我在表格视图单元格中访问数组中的第一个项目时,没有任何错误。但当我访问我的数组中的2个单元格/项目时,我收到此错误:
由于未捕获的异常'NSRangeException'而终止应用程序,原因:' * ** - [ __ NSArrayM objectAtIndex:]:索引1超出边界[0 .. 0]'
我的断点告诉我我的代码在我的prepareForSegue方法中破坏了。有人可以帮我弄清楚我的代码有什么问题吗?:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"Push"]) {
HistoryDetailsViewController *detailVC=(HistoryDetailsViewController*)segue.destinationViewController;
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
if (indexPath.section == 0)
{
NSManagedObject *YouOweData = [YouOweArray objectAtIndex:indexPath.row];
[detailVC setCellNumString:[NSString stringWithFormat:@"%@", [YouOweData valueForKey:@"youOweCellNum"]]];
[detailVC setDateString:[NSString stringWithFormat:@"%@", cell.detailTextLabel.text]];
}
else if (indexPath.section == 1)
{
NSManagedObject *TheyOweData = [SomeonesOwesYouArray objectAtIndex:indexPath.row];
[detailVC setCellNumString:[NSString stringWithFormat:@"%@", [TheyOweData valueForKey:@"theyOweCellNum"]]];
[detailVC setDateString:[NSString stringWithFormat:@"%@", cell.detailTextLabel.text]];
}
}
}
所有帮助表示赞赏,提前致谢
答案 0 :(得分:1)