|
I recently starteded working on an app for creating characters in a ttrpg. In the initial view the idea is that a characters abilities are all rolled together. After they have been rolled, they may reroll individual abilities if the scores are too low. Here is an ability:
The problem I am having is in the card subview I created, I am getting the error: "Cannot use mutating member on immutable value: 'self' is immutable". I've tried chaning Here is the card:
What am I missing here? Aren't classes supposed to be mutable? |
|
Sorry about that... protocol is:
|
|
Lol, yeah, by rolling abilities together... it is meant to simulate rolling dice to generate character stats for a role-playing game. |
|
I mucked around and got a card view to work. But removed the Ability protocol, which probably is useful for your other cards. Wasn't sure about using UInt? Is there a lesson here for us? Why UInt over a vanilla Int? Also implemented Also implemented the array of modifiers to be a computed property based on
|
|
I went with |
BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.
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.