Skip to content
Merged
Changes from 1 commit
Commits
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
4 changes: 4 additions & 0 deletions DevLog/Storage/Persistence/UserDefaultsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ final class UserDefaultsStore {

func removeAll() {
guard let bundleIdentifier = Bundle.main.bundleIdentifier else { return }
let firstLaunch = userDefaults.object(forKey: "isFirstLaunch")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

하드코딩된 문자열 "isFirstLaunch"를 사용하는 것보다, 재사용성과 유지보수성을 높이기 위해 이 키를 상수로 정의하는 것이 좋습니다. 예를 들어, private enum Keys { static let isFirstLaunch = "isFirstLaunch" } 와 같이 클래스 내에 정의하고 Keys.isFirstLaunch로 참조할 수 있습니다.

userDefaults.removePersistentDomain(forName: bundleIdentifier)
if let firstLaunch {
userDefaults.set(firstLaunch, forKey: "isFirstLaunch")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

현재 firstLaunch 객체의 타입을 확인하지 않고 다시 저장하고 있습니다. FetchFirstLaunchUseCase 등을 고려할 때 이 값은 Bool 타입이어야 할 것으로 보입니다. 타입 안정성을 높이기 위해 Bool 타입으로 캐스팅하여 저장하는 것이 안전합니다.

Suggested change
if let firstLaunch {
userDefaults.set(firstLaunch, forKey: "isFirstLaunch")
}
if let isFirstLaunch = firstLaunch as? Bool {
userDefaults.set(isFirstLaunch, forKey: "isFirstLaunch")
}

}
}