I'm trying to make it so when I press a button, I can add the cell's text and a date. For the date part, I tried looking at different Pods or Swift Manager Packages but couldn't find anything. Here's is the code so far for the addButtonPressed. I'd like to add code so I can add the date as well:
@IBAction func addButtonPressed(_ sender: UIBarButtonItem) {
var textField = UITextField()
let alert = UIAlertController(title: "Create New Category", message: "", preferredStyle: .alert)
let action = UIAlertAction(title: "Add", style: .default) { (action) in
let newProduct = Product(context: self.context)
newProduct.name = textField.text
self.products.append(newProduct)
self.saveProducts()
}
alert.addTextField { (alertTextField) in
alertTextField.placeholder = "Create new category"
textField = alertTextField
}
alert.addAction(action)
present(alert, animated: true, completion: nil)
}
And here is the simulator with what I have so far.
Thanks!