Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>But you can reload only sections which <strong>contain same number of rows</strong> <em>(or you have to manually add or remove them)</em>. Otherwise you will get:</p> <p><code> *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 2. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (0), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).' </code></p> <p>Which is not required when you use <code>[tableView reloadData]</code>.</p> <p>When you need to reload a section and you <strong>have changed number of rows inside it</strong>, you could use something like this:</p> <pre><code>NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:section]; [self beginUpdates]; [self deleteSections:indexSet withRowAnimation:rowAnimation]; [self insertSections:indexSet withRowAnimation:rowAnimation]; [self endUpdates]; </code></pre> <p>If you put it in a category (like bandejapaisa shows) it could look like this:</p> <pre><code>- (void)reloadSection:(NSInteger)section withRowAnimation:(UITableViewRowAnimation)rowAnimation { NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:section]; [self beginUpdates]; [self deleteSections:indexSet withRowAnimation:rowAnimation]; [self insertSections:indexSet withRowAnimation:rowAnimation]; [self endUpdates]; } </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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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