How to detect edit mode on iPhone UITableView
cocoa-touch, ios, iphone
Solution
It is probably not working as you expect because `willBeginEditingRowAtIndexPath:` is called before the editing starts.
If you want to check while in another method you need the `editing` property:
@property(nonatomic, getter=isEditing) BOOL editing
If you want to do something when the 'Edit' button is pressed you need to implement the setEditing method:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
Which you'll find in `UIViewController`. (Well, that's the most likely place; there are others.)
Swift Use below code accordingly:
open var isEditing: Bool // default is NO. setting is not animated.
open func setEditing(_ editing: Bool, animated: Bool)
Problem
For my iPhone app, I have an editable (for delete) table view. I'd like to be able to detect that the user has clicked the "Edit" button. See this image: http://grab.by/It0 From the docs, it looked like if I implemented : ``` - (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath ``` then I could detect it (although from the name of the method, I wouldn't think that). This proved not to work. Any ideas on detecting this? The reason I want to is I want to hook up a "Delete all" button in the upper left hand corner when in delete mode. thanks