IPhone, hook for edit/done button click in table view

iphoneuitableview

In my table view controller there is

self.navigationItem.leftBarButtonItem = self.editButtonItem;

which produces a regular edit/done button at the top left corner. Hence, once the user clicks "Edit", the button caption changes to "Done" and the table entries may be deleted or reordered. I would like to get notified once the user actually clicks "Done". Is there a hook for that?

Background: I'd like to persist the order of the entries i.e. next time the user pulls up this view I'd like to present the entries in the least recently used order.

Best Answer

for those who are still interesed in this question (or answer :P)

UITableView API

revealed that there is a - (void)setEditing:(BOOL)editing animated:(BOOL)animate method these method is called every time this edit/done button is pressed. you have to simply check by the (BOOL)editing parameter wich one was used. last but not least you have to call the proper method from the originally edit/done button.

simply add this method to your uitableview class

- (void)setEditing:(BOOL)editing animated:(BOOL)animate
{
    [super setEditing:editing animated:animate];
    if(editing)
    {
        NSLog(@"editMode on");
    }
    else
    {
        NSLog(@"Done leave editmode");
    }
}
Related Topic