I was testing an app on Xcode and I got this error saying that an exception has been thrown. Using the debugger, I added an exception breakpoint which led me to this:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.delegate = self;
int index = [[NSUserDefaults standardUserDefaults] integerForKey:@"ChecklistIndex"];
if (index != -1) {
Checklist *checklist = [self.dataModel.lists objectAtIndex:index];
[self performSegueWithIdentifier:@"ShowChecklist" sender:checklist];
}
}
With this being the highlighted line:
Checklist *checklist = [self.dataModel.lists objectAtIndex:index];
And the debugger said this:
-[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array
I'm not too sure how to fix this. If any more information is needed let me know. Thanks.
@try {} @catch {}block...?