Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding Insert Row in tableView
    primarykey
    data
    text
    <p>I have a tableView that loads its data directly from a Core Data table with a NSFetchedResultsController. I'm not using an intermediate NSMutableArray to store the objects from the fetch results; </p> <p>I basically implemented inside my UITableViewController the protocol method numberOfRowsInSection and it returns the numberOfObjects inside a NSFetchedResultsSectionInfo.</p> <pre><code>id &lt;NSFetchedResultsSectionInfo&gt; sectionInfo = [[fetchedResultsController sections] objectAtIndex:section]; </code></pre> <p>and then I configure the cell content by implementing configureCell:atIndexPath and retrieving object info from the fetchedResultController but right now I have a generic configuration for any object (to avoid complications)</p> <pre><code>cell.textLabel.text = @"categoria"; </code></pre> <p>I also have a NavigationBar with a custom edit button at the right that loads my own selector called customSetEditing. What I'm trying to accomplish is to load an "Insert Cell" at the beginning of the tableView so when I tap it, it creates a new record. This last part is easy to implement the problem is that I dont's seem to be able to load the insert row or any row when I tap on the navigation bar edit button.</p> <p>this is the code for my customSetEditing: </p> <pre><code>- (void) customSetEditing { [super setEditing:YES animated:YES]; [self.tableView setEditing:YES animated:YES]; [[self tableView] beginUpdates]; //[[self tableView] beginUpdates]; UIBarButtonItem *customDoneButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(customDone)]; [self.navigationItem.rightBarButtonItem release]; self.navigationItem.rightBarButtonItem = customDoneButtonItem; //[categoriasArray insertObject:[NSNull null] atIndex:0]; NSMutableArray *indexPaths = [[NSMutableArray alloc] initWithObjects:[NSIndexPath indexPathForRow:0 inSection:0],nil ]; [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationTop]; //[indexPaths release]; [self.tableView reloadData];} </code></pre> <p>Before adding the:<code>[self.tableView reloadData];</code> I was getting an out of bounds error plus a program crash and although the program is not crashing it is not loading anything.</p> <p>I have seen many examples of similar situations in stackoverflow (by the way is an excellent forum with very helpful and nice people) none of the examples seems to work for me.</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    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. 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