Left with extra UITableViewCell after re-ordering
Posted
by Mark F
on Stack Overflow
See other posts from Stack Overflow
or by Mark F
Published on 2010-04-15T23:09:27Z
Indexed on
2010/04/15
23:13 UTC
Read the original article
Hit count: 301
After going into Edit mode, moving a cell, and leaving edit mode, i am left with one extra cell sitting on top of its duplicate cell while still in edit mode.
The problem has to be somewhere in here:
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
NSMutableArray *array = [[fetchedResultsController fetchedObjects] mutableCopy];
id objectToMove = [[array objectAtIndex:sourceIndexPath.row] retain];
[array removeObjectAtIndex:sourceIndexPath.row];
[array insertObject:objectToMove atIndex:destinationIndexPath.row];
[objectToMove release];
for (int i=0; i<[array count]; i++) {
[(NSManagedObject *)[array objectAtIndex:i] setValue:[NSNumber numberWithInt:i] forKey:@"userOrder"];
}
[array release];
}
Any guidance greatly appreciated!
© Stack Overflow or respective owner