-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJournalListViewControllerVersion2.swift
43 lines (33 loc) · 1.33 KB
/
JournalListViewControllerVersion2.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
//
// ViewController.swift
// JRNL
//
// Created by iOS17Programming on 25/09/2023.
//
import UIKit
class JournalListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
// MARK: - Properties
@IBOutlet var tableView: UITableView!
var sampleJournalEntryData = SampleJournalEntryData()
override func viewDidLoad() {
super.viewDidLoad()
sampleJournalEntryData.createSampleJournalEntryData()
}
// MARK: - UITableViewDataSource
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
sampleJournalEntryData.journalEntries.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let journalCell = tableView.dequeueReusableCell(withIdentifier: "journalCell", for: indexPath) as! JournalListTableViewCell
let journalEntry = sampleJournalEntryData.journalEntries[indexPath.row]
journalCell.photoImageView.image = journalEntry.photo
journalCell.dateLabel.text = journalEntry.date.formatted(
.dateTime.month().day().year()
)
journalCell.titleLabel.text = journalEntry.entryTitle
return journalCell
}
// MARK: - Methods
@IBAction func unwindNewEntryCancel(segue: UIStoryboardSegue) {
}
}