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 926751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:44:11+00:00 2026-05-15T19:44:11+00:00

I am sorting the UITableView by using a predicate with NSFetchedResultsController. But, when I

  • 0

I am sorting the UITableView by using a predicate with NSFetchedResultsController. But, when I make a change in a detail view and save it, the object I changed immediately gets placed in its new location in the UITableView.

I have up/down buttons similar to the message view in Mail. This behavior disrupts the ordering of items, and I’d like to delay this change until the user backs out to the UITableView for UX reasons. I implemented the NSFetchedResultsControllerDelegate methods in the UITableViewController. Is there an easy/clever way to do this?

Edit: Below are the NSFetchedResultsControllerDelegate methods implemented in the UITableViewController.

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


- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
           atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {

    switch(type) {
        case NSFetchedResultsChangeInsert:
            [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex]
                          withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex]
                          withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}


- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath {

    UITableView *tableView = self.tableView;

    switch(type) {

        case NSFetchedResultsChangeInsert:
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]
                             withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                             withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeUpdate:
            [self configureCell:[tableView cellForRowAtIndexPath:indexPath]
                    atIndexPath:indexPath];
            break;

        case NSFetchedResultsChangeMove:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                             withRowAnimation:UITableViewRowAnimationFade];
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]
                             withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}


- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
    [self.tableView endUpdates];
}
  • 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-05-15T19:44:12+00:00Added an answer on May 15, 2026 at 7:44 pm

    The problem is not in the NSFetchedResultsControllerDelegate methods. Those methods only come into play only if something changes the data model while the table is visible.

    Your problem is that you change the data while the table view is off screen and inactive. Tableviews are designed to automatically display the data model given to them. When you return to the tableview from the detail view, it automatically reloads its data which now contains the changes made in the detail view. It would do that regardless of how you provided data to the table.

    The only way to prevent the table from displaying the changes until you want it to is to not add the data to the data model until you want the change to appear. You would have to pass the data from the detail view back to the table in a non-managedObject and create the managedObject in the tableview controller when you wanted it to appear.

    However, from a UI design perspective, I suggest you rethink your design. If you don’t change the table until after it reloads, how will you signal the users that you are going to make the change? Will the UI just suddenly update for no apparent reason? Will the user have to initiate it? What if they forget?

    I think that users will expect any changes made in the detail view to be instantly reflected in the tableview because that is how virtually all tableview-detailView pairings work. For example, if you change a contact’s name in the contact detail of the AddressBook that is reflected instantly when you go back to list of contacts.

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

Sidebar

Ask A Question

Stats

  • Questions 537k
  • Answers 537k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Seriously, everything in Guava is useful. I've been using it… May 17, 2026 at 1:38 am
  • Editorial Team
    Editorial Team added an answer Stolen from here. string GetWebPageContent(string url) { string result =… May 17, 2026 at 1:38 am
  • Editorial Team
    Editorial Team added an answer Combined maintenance- and release-branches I think you are having similar… May 17, 2026 at 1:38 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an UITableView populated by a NSFetchedResultsController . The initial fetch works fine.
I'm seeing some very strange sorting behaviour using CaseInsensitiveComparer.DefaultInvariant. Words that start with a
Does anyone know how to add a scope bar to a UITableView ? The
Sorting objects is simple enough by mixing in Ordered and providing a compare() function,
For sorting item names, I want to support numbers correctly. i.e. this: 1 Hamlet
When sorting on a column in the GridView bound to an Enum, it sorts
Which sorting algorithm is used by .NET's Array.Sort() method?
Which sorting algorithm can be used to get nearer and approximate matching list with
I need help sorting [Time] data from in this array in php. For a
i cannot use sorting on join tables. Let me explain; i have three tables.

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.