|
This application is made to visualize graph. The problem is that when we press add button we want to append node to matrix of connections. When we print size of matrix it is proper. When we want to display buttons of connections their number is static not increasing. When we added new node, number of elements in matrix has been changed, so we don't know where can be a problem.
|
|
When you use
it creates a static set of data that does not update after you add/remove items. You are using this initializer on
If you want dynamic items in your |
|
Two quick comments.
SimplifyHere's a snippet on how to simplify your button decorations. Button decorations have nothing to do with your issue. However these account for a lot of your pasted code. Simplify!
|
|
Procedural vs DeclarativeThis code seems a bit procedural. It's step-by-step instructions. Consider moving this code into your
Instead of listing the steps, consider declaring your intentions. Tell SwiftUI what you intend to do when this button is tapped.
|
|
|
|
Sure. Run the code below in the simulator. Watch what happens when you click the The first section uses an initializer on The second section uses an initializer on
The version of |
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.