Moving UITableView cells and maintaining consistent data
        Posted  
        
            by Mark F
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Mark F
        
        
        
        Published on 2010-04-15T21:35:37Z
        Indexed on 
            2010/05/09
            6:18 UTC
        
        
        Read the original article
        Hit count: 228
        
I've enabled editing mode and moving cells around to allow users to position table view content in the order they please. I'm using Core Data as the data source, which sorts the content by the attribute "userOrder". When content is first inserted, userOrder is set to a random value. The idea is that when the user moves a cell around, the userOrder of that cell changes to accomodate its new position. The following are problems I am running into while trying to accomplish this:
Successfully saving the the new location of the cell and adjusting all changed locations of influenced cells.
Getting the data to be consistent. For example, the TableView handles the movement fine, but when i click on the new location of the cell, it displays data for the old cell that used to be that location. Data of all influenced cells gets messed up as well.
I know I have to implement this in:
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {}
I just don't know how. The apple docs are not particularly helpful if you are using Core Data, as in my situation.
Any guidance greatly appreciated!
© Stack Overflow or respective owner