How to detect edit mode on iPhone UITableView

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)

Leave a Comment