I want to make static table view to pass data into coredata to add new item to my TableView, but i dont know how to connect "Done" button to make action, from another view controller (UIView).
I got this: image
I wanted to make it i one ViewController, but when i'm switching my Table View to static cells i got problem solved by this: click
So, now i got AddItemTableViewController class, and i want to run this code on my "Done" button, but i don't know how to connect that button from another view.
import UIKit
class AddItemTableViewController: UITableViewController {
@IBOutlet weak var titleTextField: UITextField!
@IBAction func doneButtonPressed(_ sender: Any) {
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let task = ItemsList(context: context)
task.title = titleTextField.text!
// Save the data to coredata
(UIApplication.shared.delegate as! AppDelegate).saveContext()
let _ = navigationController?.popViewController(animated: true)
}
}
Could you please advice, how to deal with it? thanks in advance!