Created
October 23, 2020 11:27
-
-
Save DiganVaghasiya/19fd5376dabb4a783b0324366451fa44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) | |
| { | |
| if editingStyle == .delete | |
| { | |
| self.deleteDicData(index: indexPath.row) | |
| tableView.deleteRows(at: [indexPath], with: UITableView.RowAnimation.automatic) | |
| } | |
| } | |
| The deleteDicData(index: indexPath.row) , send swiped cell indexpath in this function , and the function code is : | |
| func deleteDicData(index:Int) | |
| { | |
| let dictionary = NSDictionary(contentsOfFile: self.getpath()) | |
| var arrEmployee = dictionary?.value(forKey: "arrEmployee") as! [[String:Any]] | |
| arrEmployee.remove(at: index) | |
| dictionary?.setValue(arrEmployee, forKey: "arrEmployee") | |
| let plistContent = NSDictionary(dictionary: dictionary!) | |
| let success:Bool = plistContent.write(toFile: self.getpath(), atomically: true) | |
| if success { | |
| self.arrEmployee = arrEmployee | |
| if arrEmployee.count == 0 { | |
| lblNoData.isHidden = false | |
| } | |
| else{ | |
| lblNoData.isHidden = true | |
| } | |
| } | |
| else | |
| { | |
| print("Not written") | |
| } | |
| // self.dataTableView.reloadData() | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment