Peter Warbo
Peter Warbo

Reputation: 11718

iOS – setEditing [super setEditing...] and/or [tableView setEditing...]

If I want to put a tableView in editing mode. What is the correct call to do that? I seem to be able to put a tableView in editing mode just by calling [super setEditing:YES animated:YES] is it necessary to also call [tableView setEditing:YES animated:YES]?

Upvotes: 2

Views: 1738

Answers (2)

Paul.s
Paul.s

Reputation: 38728

A method call consists of two parts:

[messageReciever message];

In your first example you are using super which basically means send the message setEditing:animated: to the current object but start the method lookup from the super class.

In the second example you are sending the message setEditing:animated: to the tableView object.

UITableViewController implements setEditing:animated: and toggles the edit mode of it's tableView. There is not really any need to use super as using self would have the same effect. If you was to override setEditing:animated: to add additional behaviour, your use of super would cause your additional code to be bypassed.

Upvotes: 0

omz
omz

Reputation: 53561

I assume that you're calling this in a subclass of UITableViewController? In this case, the call to super is sufficient because UITableViewController automatically puts its table view in editing mode when the view controller itself starts editing.

If you'd have a regular UIViewController that just happens to also contain a UITableView, you would have to do that yourself.

Upvotes: 1

Related Questions