Reputation: 739
I wrote the following code. I'm trying to make it so that it functions like act like UIBarButtonItem
edit item function, but using a UIButton
instead because I have a custom navigation bar, but I'm having several compiling errors. The function is supposed to allow editing when the button is pressed and finish editing when pressed again.
@IBAction func edit(sender: UIButton){
if [tableView.isEditing] == YES {
[self.tableView .setEditing(false, animated: false)]
}
else{
[self.tableView .setEditing(true, animated: true)]
}
}
Upvotes: 1
Views: 424
Reputation: 562
You're mixing up Swift and Objective-C code, should look something like this
@IBAction func edit(sender: UIButton) {
if tableView.isEditing {
tableView.setEditing(false, animated: false)
} else{
tableView.setEditing(true, animated: true)
}
}
Upvotes: 1