Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

일기장 [STEP 2] Zion, Serena #136

Open
wants to merge 36 commits into
base: ic_9_serena
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f14e295
feat: CoreData과 DiaryCoreData 생성 및 CRUD 구현
serena0720 Sep 11, 2023
f586ac6
feat: ActivityViewControllerShowable, AlertControllerShowable 타입 구현완료
LeeZion94 Sep 11, 2023
8536d5c
feat: ViewController에 Showable Type 적용
LeeZion94 Sep 11, 2023
359557c
refactor: AppManager에 DiaryDataManager 주입
serena0720 Sep 11, 2023
165c338
refactor: DiarySample 삭제 및 DiaryEntity 타입 적용
serena0720 Sep 11, 2023
0759a83
refactor: DiaryEntity 변수 타입 수정 및 컨벤션 수정
serena0720 Sep 11, 2023
8195eef
refactor: DiaryDetailViewController 파라미터 수정
serena0720 Sep 11, 2023
39faa79
feat: createDiaryData 생성
serena0720 Sep 12, 2023
c5c5b60
feat: viewWillAppear 시 dataFetch
LeeZion94 Sep 12, 2023
469ba3a
feat: DiaryDetailViewController Update 기능 연결
LeeZion94 Sep 12, 2023
723ae29
refactor: 불필요 커밋 삭제
LeeZion94 Sep 12, 2023
701dba8
feat: deleteAction 구현
serena0720 Sep 12, 2023
f5dee66
feat: DiaryDetailViewController Delete 메소드
serena0720 Sep 12, 2023
500f635
feat: Update, Create 예외처리 추가
LeeZion94 Sep 12, 2023
9fcf716
feat: TextView EndEditing시 Save로직 추가
LeeZion94 Sep 12, 2023
6c34cff
feat: NotificationCenter Observer 등록
serena0720 Sep 12, 2023
97bb291
feat: background 시 create 로직 추가 및 예외처리
LeeZion94 Sep 12, 2023
9974d9a
feat: Activity Share Action 생성
serena0720 Sep 12, 2023
9269899
feat: date 출력 추가 및 becomeResponder 추가
LeeZion94 Sep 12, 2023
bc89e58
feat: diffableDataSource delete시 bottom Constraint 충돌해결
LeeZion94 Sep 12, 2023
b5ae868
refactor: 사용하지 않는 model 삭제
LeeZion94 Sep 12, 2023
021fc0f
refactor: private 누락 수정
serena0720 Sep 14, 2023
7125c8a
fix: title만 존재할경우 body도 title처럼 나오는 이슈 수정
LeeZion94 Sep 14, 2023
9cce9b2
Merge remote-tracking branch 'origin/Step2' into Step2
LeeZion94 Sep 14, 2023
21cc6ff
fix: insertData로직 추가 및 data Create반환 값 삭제, DiaryCoreDataManager 삭제
LeeZion94 Sep 14, 2023
678318f
refactor: 불필요한 메소드 삭제
serena0720 Sep 14, 2023
d97d383
refactor: insertData 에러 수정
serena0720 Sep 14, 2023
c41d293
feat: CoreData 수정 및 DiaryContentsDTO 생성
LeeZion94 Sep 14, 2023
575b0cd
feat: DiaryDetailViewController UseCase 생성 및 적용
LeeZion94 Sep 14, 2023
258deca
feat: 누락 수정사항 추가
LeeZion94 Sep 14, 2023
12cccf3
feat: CoreDataManagerType 생성 및 적용
LeeZion94 Sep 14, 2023
0d8b23d
fix: Save 시 Fetch 타이밍 수정
LeeZion94 Sep 14, 2023
ed70720
fix: Delete가 되지 않는 문제 수정
LeeZion94 Sep 14, 2023
c5a27c2
docs: Step2 README 작성
serena0720 Sep 15, 2023
b3a7146
chore: 컨벤션 통일
serena0720 Sep 17, 2023
8fc9f0e
Merge branch 'Step2' of https://github.com/serena0720/ios-diary into …
serena0720 Sep 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: background 시 create 로직 추가 및 예외처리
  • Loading branch information
LeeZion94 committed Sep 12, 2023
commit 97bb2915efa870c48e31debcb2a193528fca064c
9 changes: 6 additions & 3 deletions Diary/Controller/DiaryDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import UIKit

protocol DiaryDetailViewControllerDelegate: AnyObject {
func createDiaryData(text: String)
func createDiaryData(text: String) -> DiaryEntity?
func updateDiaryData(diaryEntity: DiaryEntity, text: String)
func deleteDiaryData(diaryEntity: DiaryEntity)
func popDiaryDetailViewController()
Expand All @@ -24,7 +24,10 @@ final class DiaryDetailViewController: UIViewController, AlertControllerShowable
return textView
}()

private lazy var isUpdate = diaryEntity != nil
private var isUpdate: Bool {
diaryEntity != nil
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isUpdate가 무엇을 의미하나요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entity의 유무를 기준으로 update를 할지, create를 할지 분기처리하였습니다!
하여 isUpdatetrue인 경우 create가 아닌 update를 타게 됩니다.


private var diaryEntity: DiaryEntity?
weak var delegate: DiaryDetailViewControllerDelegate?

Expand Down Expand Up @@ -103,7 +106,7 @@ final class DiaryDetailViewController: UIViewController, AlertControllerShowable

delegate?.updateDiaryData(diaryEntity: diaryEntity, text: text)
} else {
delegate?.createDiaryData(text: text)
diaryEntity = delegate?.createDiaryData(text: text)
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions Diary/Manager/AppManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ extension AppManager: MainViewControllerDelegate {

// MARK: - DiaryDetailViewControllerDelegate
extension AppManager: DiaryDetailViewControllerDelegate {
func createDiaryData(text: String) {
guard let (title, body) = convertDiaryData(text: text) else { return }
func createDiaryData(text: String) -> DiaryEntity? {
guard let (title, body) = convertDiaryData(text: text) else { return nil }
let date = Date().timeIntervalSince1970
let diaryEntity = diaryDataManager.createDiaryData(title: title, body: body, date: date)

diaryDataManager.createDiaryData(title: title, body: body, date: date)
diaryDataManager.saveContext()
return diaryEntity
}

func updateDiaryData(diaryEntity: DiaryEntity, text: String) {
Expand Down
3 changes: 2 additions & 1 deletion Diary/Manager/DiaryCoreDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
//

final class DiaryCoreDataManager: CoreDataManager {
func createDiaryData(title: String, body: String, date: Double) {
func createDiaryData(title: String, body: String, date: Double) -> DiaryEntity {
let entity = DiaryEntity(context: context)

entity.title = title
entity.body = body
entity.date = date
return entity
}
}