|
Hello, I have a table for creating an invoice where user needs to add the concept, quantity, price and tax in each row. I need to update the "total" text so every time the user changes some value, the total row is updated. How can I achieve that behaviour? I was thinking about computed property but it can't be a @State property. Thank you very much. |
|
Make your
(Ignore the specific details of the calculation and just look at the functionality.)
|
|
Hello, the 'total' variable doesn't update after price or quantity changed. Is there a way to recalculate the amount every time user changes anything? |
|
Not sure if it is still an open question, but roosterboys response doesn't work as Mattiav8 notes. It seems like it should work, and I'm not sure why it doesn't. Anyway, the following does work:
|
|
The solution I posted works just fine for me. Works the same as the solution posted by @sbolin (except that the currency is formatted). In thinking about it, though, it might make sense to change things a little like so:
|
|
Sorry for the late response, thank you very much to all of you for the help, it works perfectly!! |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's all new Paywall Editor allow you to remotely configure your 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.