-
Notifications
You must be signed in to change notification settings - Fork 1
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
CoreData에서 Page 데이터 읽어오기 및 보여주기 (멀티미디어 포함 X) #101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니더 ~~
역시 빛영현
public struct BookCoverDTO { | ||
let identifier: UUID | ||
let id: UUID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifiable을 안쓰는데 id로 바꾸신 이유가 있나용 ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 곳 들과의 통일성을 위해서 바꿨습니다 ! Entity와 DTO, CoreDataModel 각각의 attributes 이름이 같아야 헷갈리지 않을 것이라고 생각하여 바꿔줬습니다!
public func create(data: BookCoverDTO) async -> Result<Void, MHDataError> { | ||
let context = coreDataStorage.persistentContainer.viewContext | ||
do { | ||
try await context.perform { | ||
guard let entity = NSEntityDescription.entity(forEntityName: "BookCoverEntity", in: context) else { | ||
throw MHDataError.noSuchEntity(key: "BookCoverEntity") | ||
} | ||
let bookCover = NSManagedObject(entity: entity, insertInto: context) | ||
bookCover.setValue(data.identifier, forKey: "identifier") | ||
bookCover.setValue(data.id, forKey: "id") | ||
bookCover.setValue(data.title, forKey: "title") | ||
bookCover.setValue(data.category, forKey: "category") | ||
bookCover.setValue(data.color, forKey: "color") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코어데이터 CRUD 에 대한 메소드가 do-catch부터 entity 꺼내는 로직 등등 겹치는게 많아서
perform 처리하는 메소드를 지난 PR에서 만들어뒀습니다 !
이걸로 수정하는 건 어떨까요 ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
모두 수정했습니다 .ᐟ.ᐟ
추가로 perform 메소드는 CoreDataStorage 객체를 가지고 있는 모든 곳에서 공통적으로 사용되는 메서드라 판단하여 CoreDataStorage의 internal 메서드로 빼주어 추가적인 보일러 플레이트 코드를 방지하도록 코드 수정했습니당 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
역시.. 말 안 해도 알아서 해주는 빛영현
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
영현님 너무 고생 많으셨씁니다!! 빛빛빛...
#️⃣ 연관된 이슈
⏰ 작업 시간
Swift6 이슈로.. 화면이 되는지 확인하는데 시간을 거의 다쓴..
📝 작업 내용
PageViewController
에 띄운다.BookUseCase
,BookRepository
Sendable 채택📸 스크린샷
테스트용으로 CoreData에 저장한 Book
📒 리뷰 노트