Skip to content

Commit

Permalink
fix: 캘린더 추가 예외 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
chayoosang committed Mar 29, 2023
1 parent f574d5e commit 6e31da1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion KeKi.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions KeKi/Scenes/Calendar/DayAddViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,37 @@ class DayAddViewController: UIViewController {
}

@objc func addDay() {
if dayType != .numDay {
if date > Date() {
showAlert(title: "날짜 오류", message: "미래 날짜가 아닌 과거 날짜를 선택해주세요")
return
}
}else {
if date < Date() {
showAlert(title: "날짜 오류", message: "과거 날짜가 아닌 미래 날짜를 선택해주세요")
return
}
}

let dateFormat = DateFormatter()
dateFormat.dateFormat = "yyyy-MM-dd"
let dateText = dateFormat.string(from: date ?? Date())
var hashTags: [HashTagList] = []


hashTagList.forEach {
if $0.1 == true {
hashTags.append(HashTagList(calendarHashTag: $0.0))
}
}

if hashTags.count() == 0 {
showAlert(title: "태그 오류", message: "태그는 1개 이상 선택해주세요.")
return
}



let calendarRequest = CalendarRequest(kindOfCalendar: dayType.rawValue, title: titleTextField.text ?? "", date: dateText, hashTags: hashTags)

if titleTextField.text == nil || titleTextField.text == "" {
Expand Down Expand Up @@ -272,6 +294,12 @@ class DayAddViewController: UIViewController {
}


func showAlert(title: String, message: String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "확인", style: .default))
self.present(alert, animated: true)
}



}
Expand Down

0 comments on commit 6e31da1

Please sign in to comment.