|
I am very new to swiftui and coding all together and cannot not figure this one out. I simply want to create a button on my home tab that changes "selectedtc" (Selected team color) to the value that is set to that team. that way I can change all text and image colors to the color that the user selects througout all of my screens. on the button, the title is listed as team 1. the action is set to change selectedtc to .blue but it states "Cannot assign to property: 'user' is a get-only property" Home tab code:
|
|
|
|
@Brandon wants to be more observant.
Welcome to HackingWithSwiftUIPlease follow the course! Watch the videos. Type out all the examples. And complete the assignments. In your code above, you're using older protocols (eg Our host @twoStraws has a fantastic progression of lessons that will help you understand concepts in bite-sized pieces. If you're not following the progam, you're missing out on a nice treat. Plus, you'll end up in a bad alley (like your code above) and bump your head wondering why your (old? malformed?) code isn't working. Follow the program and you'll put the pieces together. Sample CodeAdd this code to a new project and see if this works?
Keep CodingPlease return here and let us know how you solved your issue. Plus, we'd like to know what day of the 100 Day programme you're on. One last thing, there is no need to abbreviate your variables. This is totally unnecessary!
Instead, simply write out clear, long variable names describing what you're storing! Xcode has great features to autocomplete variable names as you type them out. Future you will be thankful that you took the time to spell out your variables. |
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!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.