Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8111325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:04:23+00:00 2026-06-06T02:04:23+00:00

I have a UITableView which is configured to allow rows to be moved between

  • 0

I have a UITableView which is configured to allow rows to be moved between sections when in editing mode. The table is backed using NSFetchedResultsController

It’s hard to describe the problem that I’m seeing, but essentially:

1) The users start to drag a row

2) The other rows move out of it’s way as it’s dragged around the table

3) The user releases the touch and I respond to the moveRowAtIndexPath: callback (code
below) by updating the ManagedObject appropriately

4) Now, for some reasons the other rows animate back to where they were before the user started dragging. That is, the all move up or down one row to where they were before, rather than staying in their new position.

Some time later, generally between 0.5 seconds and 3 seconds, the NSFetchResultsController decides to ask me to update the moved cell. At this point I end up calling [table beginUpdates] and [table endUpdates] and the rows move to where they should do.

Now, the late callback from NSFetchResultsController is an oddity but that does seem to matter. What matters is that the UITableView doesn’t leave the rows in the new location and the begin/end updates call is required to put the rows where they should be. Should I be doing something else in this callback:

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
    NSLog(@"UI is moving row from [%d, %d] to [%d, %d]", fromIndexPath.section, fromIndexPath.row, toIndexPath.section, toIndexPath.row);

    self.inManualReorder = YES;

    // Here I update the underlying object, code is not relevant as this works.

    ...

    // I've tried saving the context here and delaying it untill later on. It doesn't affect
    // the behavior in question.

    NSError *error = nil;
    if (![self.managedObjectContext save:&error]) {
        // Replace this implementation with code to handle the error appropriately.
        // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }

    self.inManualReorder = NO;

    NSLog(@"UI finished moving row");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:04:24+00:00Added an answer on June 6, 2026 at 2:04 am

    I’ve found it.

    In the call backs to controllerWill(Did)ChangeContent I was calling begin(end)Updates. I shouldn’t do that if the reordering comes from a manual intervention:

    - (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
    {
        if (!self.inManualReorder)
            [self.tableView beginUpdates];
    }
    

    I was checking this flag for the didChangeObject: callback, but not for these…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView which is backed by a NSFetchedResultsController . I would like
I have a UITableView with 3 empty rows. The user can select which text
I have a UITableView which loads data from XML using the below code. It
I have a UITableView which I present in a UIPopoverController . The table view
I have three rows which are configured programmatically. I want to place an image
I have UITableView with custom cells, which contain uilabels. I am using it to
I have a UITableView with reorderable rows and I'm using the standard UITableViewCell.text property
I have a UITableView which contains names in each row alongwith images for each
I have a UITableView which displays about 5 cells at a time, yet in
I have a UITableView which I want to populate with details from an array

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.