Skip to content

Commit

Permalink
[Fix/#75] index out of range 오류 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoe0929 committed Aug 2, 2024
1 parent 15b023d commit 5d03f27
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ final class ChallengeViewModel: ObservableObject {

let calendar = Calendar.current

if todayIndex >= 0 {
if todayIndex >= 0 && statuses.count > 0{
for index in 0..<todayIndex {
if statuses[index] == "NONE" {
if let newDate = calendar.date(byAdding: .day, value: index, to: start) {
Expand All @@ -151,14 +151,14 @@ final class ChallengeViewModel: ObservableObject {
}
}
} else {
for index in 0..<days {
if statuses[index] == "NONE" {
if let newDate = calendar.date(byAdding: .day, value: index, to: start) {
let formattedDate = dateFormatter.string(from: newDate)
dates.append(formattedDate)
}
}
}
// for index in 0..<days {
// if statuses[index] == "NONE" {
// if let newDate = calendar.date(byAdding: .day, value: index, to: start) {
// let formattedDate = dateFormatter.string(from: newDate)
// dates.append(formattedDate)
// }
// }
// }
}
return dates
}
Expand Down

0 comments on commit 5d03f27

Please sign in to comment.