I was trying to make a module using Swift that can add a class to the database(ClassA.plist). The code is like this:
class AddClass:UITableViewController {
@IBOutlet weak var txtClassName: UITextField!
@IBAction func Save(_ sender: Any) {
let plistPath = Bundle.main.path(forResource: "ClassA", ofType:"plist")
let array = NSMutableArray(contentsOfFile: plistPath!)
let AddData = NSDictionary(object: txtClassName.text!, forKey: "name" as NSCopying)
array?.add(AddData)
array?.write(toFile: plistPath!, atomically: false)
DispatchQueue.main.async {
super.tableView.reloadData()
}
}
And my storyboard is like this:
However, as I write something in the textfield and click Save, nothing changed in my database. No waring, error or logs is shown.Does anyone know how to solve this problem?