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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:26:46+00:00 2026-05-13T22:26:46+00:00

I have an app wherein the datasource for a UITableView updates by a background

  • 0

I have an app wherein the datasource for a UITableView updates by a background thread from a remote server every 30 seconds.

A crash occurs if the user is scrolling the tableView or if the tableView is in process of reloadTableView:. The reason for crash is that number of rows in table at the time of the crash doesn’t match the number of rows at the time the redraw started.

Another crash happens when a requested TableView cell is out of range because, between the time numberofTableViewCells: is called and the time cellfForRowAtIndexPath is called, the datamodel has changed and the cell is no longer there.

The data for the tableView is updated from a background thread. While data is loaded from a server, the user should still be able to interact with tableView but right now that causes a crash.

How do I block the tableView from scrolling or reloading while I update tableViewDataSource?
What is the best practice for this kind of situation?

Thanks.

  • 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-13T22:26:46+00:00Added an answer on May 13, 2026 at 10:26 pm

    The short answer is that you need to buffer the data in your data model and only update the table with the new data when the table is not being scrolled. That needs to be done in the data model because the datasource delegate has no idea what is inside the data model or what has changed.

    However, from a UI design perspective, having a table actively updating while the user is scrolling will disorient the user. The user will think they are in the top/middle/bottom of the table then suddenly find themselves in the bottom/top/middle. The user will think that they have viewed all the data in one section of the table but in reality the table will have added something they needed to see. For example, if the table is a list of alphabetized names, the user checks all names staring with “U”, sees that there are none and then goes to check somewhere else in the table. Meanwhile, the table invisibly updates the “U” section with fresh names while the user is looking elsewhere. Even if the user understands that the table is dynamically updated (which most are not) they will have to continually scroll around checking virtually the entire table to see what has changed.

    A better UI design is to give the user the ability to update. Put an “Update” or “New Data Available” button in the bar and then set it to appear when new data arrives. Upon clicking the button, freeze the table, update and only then let the user resume interaction. It would also be good design to visually flag the rows added.

    This will make the UI more understandable for the user and solve your crashing problem at the same time.

    Edit01:

    If you don’t use Core Data, in order to implement live and invisible updating of the table. you will need to freeze the in the calls – tableView:numberOfRowsInSection or – numberOfSectionsInTableView: before – tableView:cellForRowAtIndexPath: is called.

    Since – tableView:numberOfRowsInSection is called first, I would put a call there to first update and then freeze your data model. That way the data model will return the proper number of sections and rows.

    I presume you will have to divide you data model into two sections, one of which will buffer incoming data and another that will order the data for display. Your update method should move all the finalized buffered data into the display data section.

    In addition, you will probably need to set a timer for when the user is not moving the table. The timer should call the update method if the table is not being actively manipulated and then it should force an update.

    If you use Core Data, you can use NSFetchedResultController and it’s delegate methods will inform you when the data model changes. It should return the proper section and row information updated live. It’s pretty easy to drive an updating table this way. However, it will not overcome the problem of data entering the model so quickly that the model changes between method calls. You will still have to freeze and/or slow down the model. You will however, not need the timer.

    Core Data is your best option but even so it’s going to be difficult to implement because you’re trying to do something against the grain of the UI and therefore the API does not easily support it.

    Update:

    Looking back over this answer, I see that I neglected to mention [UITableView beginUpdates] which will freeze the table’s configuration while rows are added or deleted. It is paired with [UITableView endUpdates] to include the changes in the UI.

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

Sidebar

Ask A Question

Stats

  • Questions 412k
  • Answers 413k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, you can loop through the elements, get the span… May 15, 2026 at 8:16 am
  • Editorial Team
    Editorial Team added an answer try using SWFLoader May 15, 2026 at 8:16 am
  • Editorial Team
    Editorial Team added an answer Set the StoreGeneratedPattern attribute to "Identity" in your SSDL for… May 15, 2026 at 8:16 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

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.