|
So I have code that will delete a student from the Student Array. However I also need to be able to change the Active Status (Bool) from true to false. (i.e. make the student inactive).
This code is inside the class Roster. It is called from the ViewRoster.swift file, and calls the deactivate method:
When I try this I get the error: "Cannot assign to property: 'student' is a 'let' constant". The active bool in the class is a var, not a let? If you can offer any help it is greatly appreciated. Thank you, Bob |
|
Look at the
The
|
|
Thanks for the help, but I've tried this and it isn't working, I've changed the deactivate method, as you have recommended. Still getting an error.
The error is where the deactivate method is called:
Cannot pass immutable value as inout argument: 'student' is a 'let' constant I must be missing something.. Bob |
|
Hello, Your deactivate method just takes a student and your calling like so
remove the underscore and colon and try calling like this:
|
|
How is that student you are using in ViewRoster.swift defined when you call |
|
Readressing my first comment: If you defined
you can do this:
This is because |
|
Sorry, I was out most of the day. The student is struct, that I initialize in the Roster class file. Not sure if this makes sense, but I was working with the CoolBeans App and trying to follow that same logic. |
|
Thanks to all of you who helped! I figured it out (with your help)
|
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.