Skip to content

Conversation

DoyleHWorks
Copy link
Collaborator

@DoyleHWorks DoyleHWorks commented Dec 10, 2024

  • DataModel 및 비즈니스 로직 추가
    • TableView에서 스와이프로 데이터 삭제 가능
  • TableViewCell로 사용할 Custom View (ContactCell) 생성

※ TIL - Project: PokeContact - 메인 UI 구현

- Utilize ViewController's properties to use Navigation bar
- self.title, self.navigationItem.rightBarButtonItem
ContactRepository
Contact+CoreDataClass
Contact+CoreDataProperties
- ContactCell:
  - RoundImageView, UILabel, UILabel
  ( RoundImageView = UIImageView subclass )
@DoyleHWorks DoyleHWorks self-assigned this Dec 10, 2024
Copy link
Collaborator

@ericKwon95 ericKwon95 left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다~
이번에 코어 데이터 레포지토리를 추가하시면서
기능 하나 추가할 뿐인데 코디네이터부터 뷰모델까지 수정하시는 경험을 해보셨을 것 같아요.
의존성 주입을 위해 부가적인 작업이 많아지는 것이 고민되실 수 있을 것 같습니다!
그 부분을 어떻게 해소할 수 있는지도 고민해 보시면 정말 좋을 것 같아요
짱짱입니다~~!

//
//

import Foundation
Copy link
Collaborator

Choose a reason for hiding this comment

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

엔티티 클래스에 기능을 추가하거나 프로퍼티를 변경할 필요가 없다면
코드 제너레이션을 Class Definition으로 두는 것도 괜찮은 것 같아요!
그럼 파일 생성 없이 접근할 수 있어서 파일 트리를 깔끔하게 유지할 수 있더라구요
물론 명시적으로 파일을 생성해 혹시 모를 실수를 방지하는 방법도 좋다고 생각합니다~!
공식문서에서 각 옵션을 선택할 때 도움이 되는 기준을 말해주고 있어서 이것도 살짝 공유드립니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

처음에 지정한 데이터 형식을 나중에 바꿔야 할 때 그 과정이 무척 복잡해보여서 포기했었던 과정이 있는데, 어쩌면 다른 Codegen 형식을 채택했을 때 더 쉽게 해결했을지도 모르겠네요.. 말씀해주셔서 감사합니다! 무척 귀중한 인사이트에요 🙇

// MARK: - UI Configuration
private func configureUI() {
view.backgroundColor = .systemPink
self.view.backgroundColor = .systemBackground
Copy link
Collaborator

Choose a reason for hiding this comment

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

오.... 다크모드 지원을 염두에 두신건가요?!

private func configureUI() {
view.backgroundColor = .systemPink
self.view.backgroundColor = .systemBackground
self.title = "Friend List"
Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 안해서 말씀드리기 부끄럽지만,,
요런 상수들은 따로 네임스페이스를 분리해 관리하면 훨씬 관리하기 용이할 것 같아요!

enum Constant {
  enum MainVC {
    static let title = "Friend List"
    // ...
  }
}

저는 요런 방식으로 관리하는 편입니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

오, 관리하기 쉬워보이는 정말 좋은 방법이네요.. 감사합니다!
enum 개념을 좀 더 확실하게 파악해야겠다는 생각이 듭니다


import CoreData

class ContactRepository {
Copy link
Collaborator

Choose a reason for hiding this comment

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

레포지토리 패턴을 적용해 뷰모델이 직접적인 Persistence 대상을 모르도록 결합도를 낮춰주신 점 좋습니다!
프로토콜을 적용해 뷰모델과의 결합도를 더욱 떨어뜨려서
뷰모델의 테스트 가능성을 높이면 더욱 좋을 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

그렇네요, 프로토콜을 적용하면 더 깔끔하게 분리가 가능하군요! 감사합니다!

private weak var coordinator: MainCoordinatorProtocol?
weak var delegate: MainViewModelDelegate?
private let repository: ContactRepository
private(set) var contacts: [Contact] = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

외부에서는 읽기만 가능한 private(set)을 활용해 주셨군요~!
좋은 선택인 것 같아요!

tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
}

private func bindViewModel() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

뷰모델이 업데이트 되면 테이블뷰 데이터를 reload 해주는군요.
클로저로 구현한 부분을 나중에는 Combine으로 한 번 바꿔보는 것도 좋은 공부가 될 것 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Combine.. 빨리 공부해서 써보고 싶네요!

}

// MARK: - ImageView Subclass
class RoundImageView: UIImageView {
Copy link
Collaborator

Choose a reason for hiding this comment

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

layoutSubviews 타이밍에 bounds에 맞춰 cornerRadius를 주기 위해 RoundImageView를 만드셨군요!
짱짱입니다~~!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

오 맞아요! 이런 식으로 쓰는 건 처음이었어서 무척 재밌었어요!!

}

private let nameLabel = UILabel().then {
$0.font = UIFont.monospacedSystemFont(ofSize: 16, weight: .regular)
Copy link
Collaborator

Choose a reason for hiding this comment

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

요 monospacedSystemFont 고민하신거 넘 멋집니다
저는 이번에 처음 알았어요! 잘 배워갑니다~!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

불편 센서가 개발자에겐 도움이 된다는 게 참 재미있는 것 같아요 😂
글자 간격이 딱 안 떨어지는 게 너무 불편했어요

@DoyleHWorks DoyleHWorks merged commit 30ae774 into SpartaCoding-iOS05-i:feat-DoyleHWorks-lv1 Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants