Skip to content

Commit

Permalink
style: 코드 컨벤션 수정 진행
Browse files Browse the repository at this point in the history
  • Loading branch information
hemg2 committed Sep 5, 2023
1 parent a7c664a commit e9a475c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Diary/Controller/CreateDiaryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ final class CreateDiaryViewController: UIViewController, AlertDisplayable, Share

return textView
}()

private let container = CoreDataManager.shared.persistentContainer
var diary: Diary
var isNew: Bool
private var diary: Diary
private var isNew: Bool

init() {
self.diary = CoreDataManager.shared.createDiary()
Expand All @@ -43,7 +43,7 @@ final class CreateDiaryViewController: UIViewController, AlertDisplayable, Share
setupNavigationBarButton()
setupNotification()
}

private func configureUI() {
view.backgroundColor = .systemBackground
self.title = DateFormatter().formatToString(from: Date(), with: "YYYY년 MM월 dd일")
Expand Down Expand Up @@ -75,7 +75,7 @@ final class CreateDiaryViewController: UIViewController, AlertDisplayable, Share
let moreButton = UIBarButtonItem(title: "더보기", style: .plain, target: self, action: #selector(showMoreOptions))
navigationItem.rightBarButtonItem = moreButton
}

private func setupNotification() {
NotificationCenter.default.addObserver(self,
selector: #selector(keyboardWillShow),
Expand All @@ -94,13 +94,13 @@ final class CreateDiaryViewController: UIViewController, AlertDisplayable, Share
let cancelAction = UIAlertAction(title: "취소", style: .cancel)
let deleteAction = UIAlertAction(title: "삭제", style: .destructive) { [weak self] _ in
guard let self else { return }
CoreDataManager.shared.deleteDiary(diary)
CoreDataManager.shared.deleteDiary(self.diary)
self.navigationController?.popViewController(animated: true)
}

showAlert(title: "진짜요?", message: "정말로 삭제하시겠어요?", actions: [cancelAction, deleteAction])
}

deinit {
NotificationCenter.default.removeObserver(self)
}
Expand Down
16 changes: 10 additions & 6 deletions Diary/Controller/DiaryListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import UIKit

final class DiaryListViewController: UIViewController, AlertDisplayable, ShareDiary {
final class DiaryListViewController: UIViewController {
private let tableView: UITableView = {
let tableView = UITableView()
tableView.translatesAutoresizingMaskIntoConstraints = false
Expand All @@ -20,7 +20,7 @@ final class DiaryListViewController: UIViewController, AlertDisplayable, ShareDi

override func viewDidLoad() {
super.viewDidLoad()

configureUI()
setupNavigationBarButton()
setupTableView()
Expand Down Expand Up @@ -61,7 +61,9 @@ final class DiaryListViewController: UIViewController, AlertDisplayable, ShareDi
tableView.delegate = self
tableView.register(DiaryListTableViewCell.self, forCellReuseIdentifier: DiaryListTableViewCell.identifier)
}

}

extension DiaryListViewController: AlertDisplayable {
private func readCoreData() {
do {
let fetchedDiaries = try container.viewContext.fetch(Diary.fetchRequest())
Expand All @@ -74,7 +76,7 @@ final class DiaryListViewController: UIViewController, AlertDisplayable, ShareDi
}
}

extension DiaryListViewController: UITableViewDataSource, UITableViewDelegate {
extension DiaryListViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
diaryList.count
}
Expand All @@ -94,12 +96,14 @@ extension DiaryListViewController: UITableViewDataSource, UITableViewDelegate {

return cell
}

}

extension DiaryListViewController: UITableViewDelegate, ShareDiary {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let diaryToEdit = diaryList[indexPath.row]
let createVC = CreateDiaryViewController(diaryToEdit)

navigationController?.pushViewController(createVC, animated: true)
}

Expand Down

0 comments on commit e9a475c

Please sign in to comment.