Set action when table view cell is swiped back in a UITableIview
<p>I am using a tableview to list files . And it works perfectly. However , when I swipe left for deleting , the tableview goes into editing mode and my edit button gets overwritten by a cancel button. that is perfect as well . But when I swipe back without deleting , the button should go back to edit , which doesnt happen. Is there any delegate that gets called when a tableview cell is swiped back ? this is the related code</p>

<pre><code>- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[[NSUserDefaults standardUserDefaults]objectForKey:DOCUMENTDELETE]isEqualToString:ENABLED]) {

return YES;
} else {
    return NO;
}
}

-(void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath {
[self.tableView setEditing:NO];
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
       editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.tableView.editing) {
    return UITableViewCellEditingStyleDelete;
}
else {
    self.navigationItem.rightBarButtonItem = nil;
    self.navigationItem.rightBarButtonItem = self.cancelButton;
    return UITableViewCellEditingStyleDelete;
}
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

self.navigationItem.rightBarButtonItem = nil ;
self.navigationItem.rightBarButtonItem = self.editButton;
if (editingStyle == UITableViewCellEditingStyleDelete) {
    NSString *cellText;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
    cellText = selectedCell.textLabel.text;
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *fileName =[NSString stringWithFormat:@"/Inbox/"];
    NSString *allFilesPath = [documentsDirectory stringByAppendingPathComponent:fileName];
    NSString *theactualFilePath = [allFilesPath stringByAppendingPathComponent:cellText];

    NSError *error;

    _success = [[NSFileManager defaultManager] removeItemAtPath:theactualFilePath error:&amp;error];
     [self.tableView setEditing:NO];
    if ([_filePathsArray count] == 0) {
        [[NSUserDefaults standardUserDefaults] setObject:DISABLED forKey:NOMATCHFOUND];
        [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:ALLFILESDELETED];
        [[NSUserDefaults standardUserDefaults]synchronize];

    }
    if (_success) {
    }
    else
    {
        NSLog(@"Could not delete file -:%@ ",[error localizedDescription]);
    }
 }

[self.tableView reloadData];

}
</code></pre>

<p>this is the code in ViewDidLoad :</p>

<pre><code>if ([[[NSUserDefaults standardUserDefaults] objectForKey:DOCUMENTDELETE] isEqualToString:ENABLED]) {
    if (self.tableView.editing){
        self.navigationItem.rightBarButtonItem = nil;
        self.navigationItem.rightBarButtonItem = self.cancelButton;
    }else {
    self.navigationItem.rightBarButtonItem = nil;
[self.navigationItem setRightBarButtonItem:self.editButton];
    }} else {
        self.navigationItem.rightBarButtonItem = nil;
    }
</code></pre>

<p>Thanks in advance</p>