-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAddNoteViewContorller.swift
44 lines (31 loc) · 1011 Bytes
/
AddNoteViewContorller.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// AddNoteViewContorller.swift
// Notes
//
// Created by Bart Jacobs on 08/03/2017.
// Copyright © 2017 Cocoacasts. All rights reserved.
//
import UIKit
protocol AddNoteViewControllerDelegate {
func controller(_ controller: AddNoteViewController, didAddNoteWithTitle title: String)
}
class AddNoteViewController: UIViewController {
@IBOutlet var titleTextField: UITextField!
var delegate: AddNoteViewControllerDelegate?
// MARK: - View Life Cycle
override func viewDidLoad() {
super.viewDidLoad()
}
// MARK: - Actions
@IBAction func save(_ sender: Any) {
guard let title = titleTextField.text else { return }
guard let delegate = delegate else { return }
// Notify Delegate
delegate.controller(self, didAddNoteWithTitle: title)
// Dismiss View Controller
dismiss(animated: true, completion: nil)
}
@IBAction func cancel(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
}