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

  • Home
  • SEARCH
  • 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 303649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:12:28+00:00 2026-05-12T07:12:28+00:00

This is my first try into iPhone development and I have some UITableViewController s

  • 0

This is my first try into iPhone development and I have some UITableViewControllers which will show the data returned from a webservice.

In my AppDelegate I have setup a timer which is called every few seconds and reloads the model. I keep the same object reference and just refresh it’s contents, so I have the same object on any UITableViewController that is visible at the moment.

When the data is refreshed on the AppDelegate, I call:

[[(UITableViewController *)[self.navigationController topViewController] tableView] reloadData];

The model is basically a collection of file objects. Each file object has some properties and flags.

This works quite well if the current UITableViewController is a simple table, with one section, that maps each cell to a sequential index on the Array of files.

But I have one of the UITableViewControllers that shows this file details and, depending on a flag on the file object, will show 2 or 3 sections. I’ve put this logic here:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    if ([[_file status] intValue] & DOWNLOADING) {
        kIndexTransferSpeed = 1;
        kIndexSettings = 2;
        return 3;
    } else {
        kIndexSettings = 1;
        kIndexTransferSpeed = -1;
        return 2;   
    }
}

So on this controller, my -tableView:cellForRowAtIndexPath: is just a big if statement that will show a property from the _file object, depending on the indexPath.

The problem with this approach is that when this table is reloading on the device, I can actually see it being reloaded. The section titles flash for a moment and the cells take a bit to show up. Specially if I am scrolling the table while it’s reloaded.

I’ve read somewhere that I should keep myself from putting any logic on those UITableViewController methods. But what should I do?

I thought about having a specific method that will create a “data view model” with the data ready to be consumed by - tableView:cellForRowAtIndexPath: and would be called by the AppDelegate before calling it’s [tableView reloadData]. But I’d have to recreate this whole “view model” everytime it’s called, since it’s the same object and I don’t really know what has been changed on the data model.

  • 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-12T07:12:29+00:00Added an answer on May 12, 2026 at 7:12 am

    reloadData has to handle lots of things, including sections coming and going, objects moving in relative order etc. Without knowledge of what is actually going on there is sometimes nothing it can do but basically teardown and rebuilt the table.

    If you want to avoid that you can instead inform the controller of the specific changes that have occured. Basically instead of your view reloading all the data through the dataSource in your controller, the controller tells it specifically what to up date and how.

    It is a lot more work than just calling reload, but it is more efficient, uses less power, and because the UI has better information it not only avoids the whole thing disappearing and reappearing, but can actually animate in the changes.

    The methods you want to look at are:

    - (void)beginUpdates;   // allow multiple insert/delete of rows and sections to be animated simultaneously. Nestable
    - (void)endUpdates;     // only call insert/delete/reload calls inside an update block.  otherwise things like row count, etc. may be invalid.
    
    - (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
    - (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
    - (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
    
    - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
    - (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
    - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
    

    More documentation is available here.

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

Sidebar

Ask A Question

Stats

  • Questions 211k
  • Answers 211k
  • 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 Use for a date three days ago: WHERE t.date >=… May 12, 2026 at 10:08 pm
  • Editorial Team
    Editorial Team added an answer You have these choices (you can look them all up… May 12, 2026 at 10:08 pm
  • Editorial Team
    Editorial Team added an answer Basically it says "I am giving you this (s,b)" and… May 12, 2026 at 10:08 pm

Related Questions

Update : I edited the code, but the problem persists... Hi everyone, this is
In the iPhone Push Notification documentation, they have a code snippet in which they
I'm writing an application for the iPhone that communicates with a SQLite database but
I've been reading about Stanford's Secure Remote Password protocol , and it looks ideal

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.