Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use Core Data and correctly show animation when switching between edit mode while using an extra row to insert a new record?
    primarykey
    data
    text
    <p>I'm trying to use an extra row at the bottom of my UITableView which would be used to insert a record. This works fine, but I'm having trouble getting it to animate properly. Either the extra row is shown properly and I get no animation (by using [self.tableView reloadData] in the setEditing: method. Or, I get animation and no extra row by not using reloadData. I know that I'm probably not showing the extra row properly (returning one more row in my numberOfRowsInSection method, and using reloadData to force a refresh.).</p> <p>I know there must be a right way to do this, but I haven't seen any examples.</p> <pre><code>- (void)setEditing:(BOOL)editing animated:(BOOL)animated { [super setEditing:editing animated:animated]; [self.tableView setEditing:editing animated:animated]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { id &lt;NSFetchedResultsSectionInfo&gt; sectionInfo = [[fetchedResultsController sections] objectAtIndex:section]; if (self.editing == YES) { return [sectionInfo numberOfObjects] + 1; } return [sectionInfo numberOfObjects]; } - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath { if (indexPath.row + 1 &gt; [fetchedResultsController.fetchedObjects count]) { cell.textLabel.text = @"Add New Row..."; [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; } else { cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; MyManagedObject *aManagedObject = [fetchedResultsController.fetchedObjects objectAtIndex:indexPath.row]; cell.textLabel.text = aManagedObject.planName; } } </code></pre>
    singulars
    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. 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