Saturday, October 10, 2026
HomeiOS Developmentios - Im making an attempt to make a day picker for...

ios – Im making an attempt to make a day picker for a calendar kind app, however deciding on the day does not work for some motive. (I’ve feedback on the place the code breaks)

[ad_1]

Im making an attempt to make a day picker for a calendar kind app, however deciding on the day does not work for some motive. (I’ve feedback on the place the code breaks).

I’ve these two variables to maintain monitor:
@State var currentDate = Date()
@State var selectedDate = Date()

(I believe the issue comes from my use of the ForEach loop however I am unsure)

ForEach(0..<100) { day in

                                if (selectedDate == (currentDate + TimeInterval((86400 * day)))) {
                                    Button {
                                        selectedDate = (currentDate + TimeInterval((86400 * day)))
                                        // error right here
                                    } label: {
                                        
                                        ZStack {
                                            VStack {
                                                Textual content("((currentDate + TimeInterval((86400 * day))).formatted(.dateTime.day()))")
                                                    .foregroundColor(.white)
                                                Textual content("((currentDate + TimeInterval((86400 * day))).formatted(.dateTime.weekday(.brief)))")
                                                    .foregroundColor(.white)
                                            }
                                        }
                                    }
                                } else {
                                    Button {
                                        selectedDate = (currentDate + TimeInterval((86400 * day)))
                                        // and right here
                                    } label: {
                                        ZStack {
                                            VStack {
                                                Textual content("((selectedDate + TimeInterval((86400 * day))).formatted(.dateTime.day()))")
                                                    .foregroundColor(.white)
                                                Textual content("((selectedDate + TimeInterval((86400 * day))).formatted(.dateTime.weekday(.brief)))")
                                                    .foregroundColor(.white)
                                            }
                                        }
                                    }
                                }
                                
                                }

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments