Why does this reloadData crash my program?
1. Name A
2. Name B
3. Name C
to: (switch 1 & 3)
3. Name C
2. Name B
1. Name A
I want it to say
1. Name C
2. Name B
3. Name A
Here is the code, but I get * Terminating app due to uncaught exception 'NSRangeException', reason: ' * -[NSCFArray objectAtIndex:]: index (1) beyond bounds (1)'
Here is the Code:
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
if (fromIndexPath.section == 0) {
NSDictionary *currentName =[[[bNameChoices objectAtIndex:fromIndexPath.row] retain] autorelease];
[bNameChoices removeObjectAtIndex:fromIndexPath.row];
[bNameChoices insertObject:currentName atIndex:toIndexPath.row];
} else if (fromIndexPath.section == 1) {
NSDictionary *currentName =[[[gNameChoices objectAtIndex:fromIndexPath.row] retain] autorelease];
[gNameChoices removeObjectAtIndex:fromIndexPath.row];
[gNameChoices insertObject:currentName atIndex:toIndexPath.row];
}
[tableView reloadData];
}
Any help on this would be appreciated!
iMac 24" 2.8g, iPhone 16g Black, 2.1, iPod Touch 16g, Mac OS X (10.5.5)