bvogelzang / BVReorderTableView

Easy Long Press Reordering for UITableView
MIT License
234 stars 59 forks source link

Core Data compatible #24

Open Sun3 opened 10 years ago

Sun3 commented 10 years ago

I am trying to using the wonderful control with a UITableViewController bound to a Core Data source but one I release the drag the row always goes back immediately to original position?

Is this control compatible with Core Data, is there possible sample code?

Thank you

mluisbrown commented 10 years ago

BVReorderTableView is totally compatible with Core Data. I'm using them together in my app ThenDo (free). When you say your UITableViewController is "bound do a Core Data source" do you mean you're using NSFetchedResultsController?

You need to remember that if you're reordering your items by dragging them around, you'll also have to change whatever attribute of your object Core Data is using to order them, which may mean changing the order attribute of more than just the item you moved. It's not difficult, but you need to think about it.

Sun3 commented 10 years ago

@mluisbrown Yes, I am using NSFetchedResultsController The example project is using NSArray in the delegates and I am trying to figure out what to use since my data is not from an array.

For example what would I use below if I am using core data?

- (id)saveObjectAndInsertBlankRowAtIndexPath:(NSIndexPath *)indexPath {  
    id object = [_objects objectAtIndex:indexPath.row];
    [_objects replaceObjectAtIndex:indexPath.row withObject:@"DUMMY"];
    return object;
}

Any help is appreciated :)

Thanks.