Post

Replies

Boosts

Views

Activity

Reply to PreviewProvider view initializer compiler error with @Binding
I tried the first suggestion from robnotyou, and it seems to work without any unpleasant side effect. After voting it as the answer, the system won't let me also choose the other answer from Claude31. I've studied Claude31's answer and the info at the other thread, and I see it addresses my situation exactly. It was good to study to understand why my error happens in the first place, even if I don't yet fully understand this intricacy yet. I do want to ask: since the first solution is a lot simpler, does it risk any bad side effects somewhere along the line? I mean, why implement a stateful preview wrapper if you can just coerce the thing to preview into a constant via .constant()?
Mar ’22
Reply to How to use ForEach to increase number of rows in SwiftUI's Picker?
Yes, that fixes it, thanks. As a beginner, though, I still don't understand the solution, so I'll study that documentation. I did look up "stride" in Xcode's documentation before posting, but it showed me stride entries that gave very little information and did not fit this use with Array. Googling "swift array stride," I was led to searching the documentation for "stride(from:to:by:)," so I'm apparently a n00b at reading the manual, too, which is not normally the case, I assure you. I would like to continue to ask, though: why does ForEach(1..<31) work, but ForEach(1...31) fails?
Mar ’22