Taehyeon-Kim / Mogakco

🕹 위치 기반 스터디 매칭 서비스
https://github.com/Taehyeon-Kim/Mogakco/wiki
2 stars 0 forks source link

[Feat] 스터디 입력 화면(1_2_study) 코드 정리 #81

Closed Taehyeon-Kim closed 1 year ago

Taehyeon-Kim commented 1 year ago

todo

logic

design

Taehyeon-Kim commented 1 year ago

중복 제거

extension Sequence where Element: Hashable {
    func uniqued() -> [Element] {
        var set = Set<Element>()
        return filter { set.insert($0).inserted }
    }
}
Taehyeon-Kim commented 1 year ago

나름대로 뷰 쪽에서 로직을 짜보려고 했던 부분

private func removeDuplicatedKeywords(items: [KeywordItemViewModel]) -> [KeywordItemViewModel] { var items = items items.removeAll { viewModel in viewModel.contents == "anything" || viewModel.contents.isEmpty }

let result = Array(Set(items))
return result.sorted { first, _ in
    return first.keywordType == .recommended
}

}

Taehyeon-Kim commented 1 year ago

Reference

Taehyeon-Kim commented 1 year ago