I am making a To do list app and well I need to create a delete button so when the self (user) swipes the task to the left a red button will say delete.
So well I started to create the code imported from UITableViewDataSource
and well the code I am trying to use is if(editingStyle) == UITableViewCellEditingStyle.Delete)
and well when I put it into the code, the code throws back a error saying (!) Expected '{' after 'if' condition.
So is there anyway to get round this because I have tried to but a { after if but loads more errors come back!
Replace those 3 lines with these 4. You have a parenthesis error and a bracket error.
if (editingStyle == UITableViewCellEditingStyle.Delete) {
taskMgr.tasks.removeAtIndex(indexPath.row)
}
tblTasks.reloadData()
Also, make sure that you've properly set your UITableView dataSource and delegate. You can do this in IB or you can do this by replacing your existing viewDidLoad with:
override func viewDidLoad() {
super.viewDidLoad()
tblTasks.delegate = self
tblTasks.datasource = self
}