Created
December 28, 2016 15:02
-
-
Save bobleesj/431a59103b2aecab1ebb23e1ef7cc1ea to your computer and use it in GitHub Desktop.
This file contains 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
class AddTaskViewController: UIViewController { | |
@IBOutlet weak var taskTextField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
@IBAction func buttonTapped(_ sender: UIButton) { | |
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext | |
let task = Task(context: context) // Link Task & Context | |
task.name = taskTextField.text! | |
// Save the data to coredata | |
(UIApplication.shared.delegate as! AppDelegate).saveContext() | |
let _ = navigationController?.popViewController(animated: true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment