Take the 2-minute tour ×

I've got the UITableView which is populated from NSMutableArray. NSMutableArray was created from my NSFetchedResultsController which came from another view

  Templates *template2 = (Templates *)[fetchedResultsController objectAtIndexPath:indexPath];
        qModalView.templateObject = template2;

and was recorded to templateObject, so I have got all my objects in this my NSMutablArray that way.

[templateObject.questions allObjects];

Now I want to delete row in my table view , in array and in that particular object in templateObject.questions.

Please help, I have this so far:

    Questions *question_var = [questionsArray objectAtIndex:indexPath.row];

    NSLog(@"_____________________________%@", question_var.question_title);

    NSManagedObjectContext *context = [templateObject managedObjectContext];
    [context deleteObject:[templateObject.questions objectAtIndexPath:indexPath]];

    NSError *error;
    if (![context save:&error]) {

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You can remove the row from the table with

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]

and you can delete an object from an NSMutableArray with

[myArray removeObject:myObject];
share|improve this answer
and how do I delete it from the database? Is it happening automatically? –  Rouslan Karimov Dec 27 '10 at 17:46
You've already got the database delete, in the lines "[context deleteObject:[templateObject.questions objectAtIndexPath:indexPath]]; " and "[context save:&error]". –  Seamus Campbell Dec 27 '10 at 17:51

Your Answer


