-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathNoteViewController.swift
47 lines (33 loc) · 1.03 KB
/
NoteViewController.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
45
46
47
//
// NoteViewController.swift
// Notes
//
// Created by Bart Jacobs on 08/03/2017.
// Copyright © 2017 Cocoacasts. All rights reserved.
//
import UIKit
class NoteViewController: UIViewController {
// MARK: - Properties
@IBOutlet var titleTextField: UITextField!
@IBOutlet var contentTextView: UITextView!
// MARK: -
var note: Note?
// MARK: - View Life Cycle
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Update User Interface
titleTextField.text = note?.title
contentTextView.text = note?.content
}
// MARK: - Actions
@IBAction func save(_ sender: Any) {
guard let title = titleTextField.text else { return }
guard let content = contentTextView.text else { return }
// Update Note
note?.title = title
note?.content = content
note?.updatedAt = Date()
// Pop View Controller From Navigation Stack
_ = navigationController?.popViewController(animated: true)
}
}