Note that there are some explanatory texts on larger screens.

plurals
  1. POReload UITableView Data without reloading the view?
    primarykey
    data
    text
    <p>I have a <code>UITableView</code> that contains a bunch of items whose status I get from a web app each time the table loads via a method <code>refreshRows</code>. After I do this I reload the table.</p> <p>When I added an item to my table, I found myself getting a message “Invalid update: invalid number of rows in section”. Reloading the data in the table turned out to be necessary, so I made the change from the old to the new <code>viewDidAppear</code> methods (both shown below). I now have two <code>reloadData</code> calls, which both refresh my view.</p> <p>QUESTION: Is there a cleaner way to do this? After an add I need to reload my data, but I'd prefer not to reload the view until all the statuses from the web are fetched.</p> <pre><code>- (void)viewDidAppear:(BOOL)animated // new { NSLog(@"viewDidAppear"); [super viewDidAppear:animated]; [self.tableView reloadData]; // &lt;------------- Prettier way to do this? [self refreshRows]; [self.tableView reloadData]; } - (void)viewDidAppear:(BOOL)animated // old { NSLog(@"viewDidAppear"); [super viewDidAppear:animated]; [self refreshRows]; [self.tableView reloadData]; } - (void)refreshRows { // foreach row get status from webapp } </code></pre> <p>EDIT:</p> <p>Here's the requested code:</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { id &lt;NSFetchedResultsSectionInfo&gt; sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section]; return [sectionInfo numberOfObjects]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload