|
I'm trying to pass along information from ExerciseDetailView to MyWorkouts using @ObservableObject but I get an error under the my preview provider in MyWorkouts that says "Cannot find 'listedWorkouts' in scope. I know my code is kinda messy but please help! MyWorkouts:
|
|
The To fix the error, supply an instance of
You may need to pass arguments to the |
|
Thank you so much for the solution. I have another view named "CreateWorkoutView" and I have a ForEach loop in it. When I set "listedWorkouts" into the ForEach loop, I get an error that says, "Generic struct 'ForEach' requires 'ListedWorkoutsViewModel' conform to 'RandomAccessCollection'" How would I set ListedWorkoutsViewModel to a RandomAccessCollection if it is already an ObservableObject? I tried using a comma and the & sign but I get thrown many errors. CreateWorkoutView:
|
|
I'm assuming this is the code that is causing the error:
The reason you are getting the error is the following declaration in
The What you want to show is the array of workouts inside the view model. The following change should fix the error:
You should consider changing the name of the @ObservedObject to something besides |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.