|
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 |
TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!
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.