-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
Description
체크된 요일을
위와 같이 보여줘야함
ViewModel
func selectDay(index: Int, isSelected: Bool) {
let isBool = isSelected == false
switch index {
case 0:
monday = isBool ? week[0] : ""
case 1:
tuesday = isBool ? week[1] : ""
case 2:
wednesday = isBool ? week[2] : ""
case 3:
thursday = isBool ? week[3] : ""
case 4:
friday = isBool ? week[4] : ""
case 5:
saturday = isBool ? week[5] : ""
default:
sunday = isBool ? week[6] : ""
}
days = monday + tuesday + wednesday + thursday + friday + saturday + sundayTableViewCell
func checkImageIsHidden(_ dayViewModel: PillDayViewModel, indexPath: IndexPath) {
checkImage.isHidden.toggle()
isSelected.toggle()
dayViewModel.selectDay(index: indexPath.row, isSelected: checkImage.isHidden)
}ViewController
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let cell = tableView.cellForRow(at: indexPath) as? PillDayTableViewCell else { return }
cell.checkImageIsHidden(viewModel, indexPath: indexPath)
}String ++ Extension
extension String {
func addSeparator() -> String {
let string = self.map{String($0)}
let separator = string.joined(separator: ", ")
return separator
}
}joined
배열에 특정 요소를 추가하여 묶는 방법
시퀀스 사이에 원하는 separator를 넣어줄 수 있음 . .
생각보다 너무 간단하고 유용한 듯 . .