I am trying to delete a row from my Data Source and the following line of code:
if let tv = tableView {
causes the following error:
Initializer for conditional binding must have Optional type, not UITableView
Here is the full code:
// Override to support editing the table view.
func tableView(tableView: UITableView, commitEditingStyle editingStyle:UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
if let tv = tableView {
myData.removeAtIndex(indexPath.row)
tv.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
How should I correct the following?
if let tv = tableView {