Skip to main content

Posts

Showing posts with the label nsrangeexception

NSRangeException when deleting cell using a different class

I looked through my code and I printed my array I was using and it appears to be fine, yet this error still persists. * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM removeObjectAtIndex:]: index 1 beyond bounds [0 .. 0]' My guess was that it had something to do with my indexPath but it doesn't make much different how much I change it. -(void)checkboxTapped:(id)sender { [sender setSelected:YES]; [self.textLabel setTextColor:[UIColor grayColor]]; [self.detailTextLabel setTextColor:[UIColor grayColor]]; parent = [[ViewController alloc] init]; UITableView *tableView = parent.tableView; NSMutableArray *array = [[NSMutableArray alloc] initWithArray:parent.array]; [parent release]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[array count] inSection:1]; [array removeObjectAtIndex:[indexPath row]]; [db deleteTaskAtIndex:[indexPath row]]; [tableView deleteRowsAtIndex