I'm having trouble deleting records from Core Data SQLite file. I want to be able to delete the corresponding record from my file when I delete a row from my table view.

Here is what I am doing after fetching all records into `allContacts` array

```
NSManagedObject *contactRecord = [allContacts objectAtIndex:arc4random() % allContacts.count];
self.managedObjectID = [contactRecord objectID];

```

Then called my method that prepares my contacts and then display them on the tableview.

When I delete a row from the table, I call this method

```
-(void)deleteContactFromFile:(contact *)deletedContact
{
    NSLog(@"deleted Contact %@",deletedContact.personID);
    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    NSManagedObjectContext *context = appDelegate.managedObjectContext;
    [context deleteObject:[context objectWithID:self.managedObjectID]];
    [context save:nil];
}

```

The funny thing is I get a random record deleted from my core data file, but not the one I selected. I don't know how to deal with `ObjectID` thing for deleting a specific `NSManagedObject`.

If my question is not clear enough please tell me to clarify more.